Adding some logic to clean up the player when it has been removed from the DOM.