Session Not Ending After Window Closure

I'm working on my first Python Shiny app and am running into an issue with it running on Posit Connect.

When the user disconnects from application, it doesn't look like the app stops running. It still shows as active on the Admin metrics page. I see there is the session.close() method, but the example in the documentation requires the user to click a button to stop the session.

Is there a way to automatically stop the session on window closure?