Hi folks, I'm trying to write a python script addon for xbmc. The script shall make use of multiple threads, some listening on sockets, some waiting for callbacks to xbmc.Player.onPlayBackEnded() etc etc...

Now my question relates to how to "gracefully" let XBMC kill a python script. Currently my script is run from within the Programs section of the main menu. It starts when you click the script once... and it will try to stop it when you click it again. Now the problem is, how can my script detect that XBMC wants it to die, and then cleanup and die gracefully. Sockets have to be closed, threads have to end, resources have to be released. I cannot see how this should happen in the context of XBMC. My current problem is that i get the following error...