Avoid crash when stopping playback while the player is the foreground activity