WebSession.Closing
From Xojo Documentation
Event
The current session is closing.
Notes
This is where you do any cleanup after as the session is in the process of closing.
A session begins to close automatically when the user navigates away from your app. This could be by navigating to another URL or by closing the tab or window. You can manually end a session by redirecting the user away from the app yourself using ShowURL. After the user navigates away, the session automatically closes when the UserTimeOut property value is reached. The default is 3 minutes. If the user returns to your app (via Back or re-entering the URL) before the timeout, then the session will still be available for use.