Apparently, the ‘pause’ function is keeping track of where the playing was at the time, and disregarding anything but a resume command.
So, my suggestion is that, if you leave the media screen, you issue a ‘resume’ and immediately call ‘stop’.
As the two functions would be one after the other, they would run in a fraction of a second, and no real music would have had the time to play before the playing is overall cancelled.
Sometimes, you have to adapt your code to the limitations imposed by other choices.That would be such an instance.