Due to the way that BackgroundAudio task and app lifecycle are built up, there doesn't seem to be a way to detect actual closing of the app and stopping its background task at this point. This creates an odd situation for the user, where she can try to forcibly terminate the suspended-but-present app to "get rid" of the playing audio, yet the playback continues.
There is a possibility of reacting to the Suspending event, but that would just mean that the audio stops playing as soon as the user switches out of the app. However, we are required to stop audio playback only when the user terminates the app via App Switch screen.
Is there any way of detecting that the app has been closed from its background task?
The BackgroundAudioTask is designed to continue even the main app has been terminated/suspended. There is no way to inform the BackgroundTask that the suspended app has been terminated.
After the app is suspended, no events are called or any code is run from your app. The last things what you can do is to put something into suspending event and/or window's events. You can save something in LocalSettings which will be inform the BackgroundTask that the app is inactive, it's also last chance to send a message to your task with information about UI status.
The above method is used in official MSDN sample.