How do I make my app do so thing when the user exits the app?

Can I make my app play a player or do something when the user exits it maybe with some extensions or smthn

Use the ActivityChanged event from the tools extension

if state = stop
then do something

Taifun