I’ve read a similar story about PowerAmp and unplugging headsets with controls:
If it’s not related to plugging in/out headphones, there’s an unfortunately unsolved similar issue here: