On iOS, how do I fade out music when the user presses the home button?

All the well-behaved games I've played on iOS fade out their audio when you push the home button. It's a cool effect, because it lasts until just after the home screen appears, making for a very smooth transition.

From what I have read, Application.Quit(), Application.CancelQuit() and MonoBehaviour.OnApplicationQuit() don't work/aren't called on iOS. This makes it difficult to detect when the user has pushed the home button. By default, my app's music is playing, so it continues to play until just after the home screen appears, and then it cuts off.

How do I make a Unity app handle quitting elegantly?

just dieing IS by apples definition quitting elegantly actually. you aren't meant to pull resources when the OS kills you.