On close / destroy / end / exit or some like this event

You can use the app states, to perform a last action if possible or combine with the background process extension.

Extension - Activity Lifecycle of an app (onPause → onStop → onResume) - Extensions - MIT App Inventor Community

Taifun extension that lets you know the status of the app
App Inventor Extensions: Tools | Pura Vida Apps

This is an extension in which you could combine or make a process to be performed when the app is paused or stopped (which is the same thing).

1 Like