title: Unable to set AudioSession inactive with AVPlayer
body: <p>I am using an <code>AVPlayer</code> to playback audio in my iOS app (because the audio files I'm playing are not local), and when my track finishes, I want to hide the InfoCenter controls, but I get this error:</p>
  
  <p><code>AVAudioSession.mm:1079:-[AVAudioSession setActive:withOptions:error:]: Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session.</code></p>
  
  <p>I am however pausing my <code>AVPlayer</code> before.</p>
  
  <p>This is my code:</p>
  
  <pre class="lang-swift prettyprint-override"><code>player.pause()
  player.replaceCurrentItem(with: nil)
  
  MPNowPlayingInfoCenter.default().nowPlayingInfo = nil
  try? audioSession.setActive(false, options: .notifyOthersOnDeactivation)
  </code></pre>
  
  <p>Due to this error, the native controls remain visible, but don't work anymore.</p>
  
  <p><a href="https://i.stack.imgur.com/tXTsS.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/tXTsS.jpg" alt="enter image description here"></a></p>