Does app quit if user closes page?


If I have an app running and the user closed the page, will the app quit?

Also if it’s running in a frame and the user closes the page that has the frame does the app quit?

If I look in running processes on the server, some of my apps seem to have been running for hours.


As per default:

  • CGI quits automatically
  • Standalone keeps running

More information in the docs: AutoQuit and SessionTimeout :slight_smile:

OK here’s what i found.

I set the sessionTimeOut = 300

After the user has finished the transaction I kicked off a timer
The timer is set for 2:00

In the action is:
Session.sesAspeDB = nil
Session.sesWebDB = nil

The 2 session vars are MySql DB

After the timer fires it’s still shown in running processes.

After the 5:00 sessionTimeOut it is still in running processes.

Why won’t it quit?

Do you compile as CGI or as standalone?
In the latter case, are you sure you want the application to quit if the session closes? Once quit, the application won’t automatically restart and any subsequent user won’t be able to connect.

Anyway, the setup described sounds a bit uncommon to me. I’d suggest trying this:

  • in the App.Open event, call App.AutoQuit = True, App.TimeOut = 1 and App.SessionTimeout = 1
  • in the Session.Open event, call Self.TimeOut = 300, which calls the TimedOut event after 5 minutes (maybe something shorter for testing purposes?)
  • in the Session.TimedOut event, call Self.Quit

To test, you need to compile (not debug run), run the application, connect to it within your browser and then close the browser window. Wait for the period previously defined and you should see the app terminating. Bear in mind that this only works if no other session is active, i.e. no other browser/window/tab is connected to the application.

Alternatively, you may also add a button (or a timer, if you want) calling Session.Quit, which ignores the TimeOut period and immediately terminates the session.
If you call App.Quit instead, the application is supposed to terminate instantly - so no Session.Quit is required.

You shouldn’t need to nil the database properties because the framework is supposed to do that for you when destroying the session object.

Works fine here, see example:

Sorry forgot to mention, this is cgi.

I will test this tomorrow.

Thanks for the detailed reply!

The example was created with standalone compilation in mind, CGI is a different story in some aspects (cf. AutoQuit above). It should still work, though. Bear in mind that debugging (“run” instead of “build”) will run as standalone instead of CGI, no matter what you chose in the build settings

Yea, I’m actually running it on the server for that reason.

I downloaded your sample app and set it to cgi, here’s the results:

When pressing the quick session now button the app remained in memory even though it went off-line. I waited well past the one minute time out. I did not close the tab.

Pressing the quit session button and immediately closing the tab the app is removed from memory.

When I just close the tab that the app Was running in, after the timeout the app was no longer in memory.

When I hit the button quit session after 10 seconds, the app went off-line as expected however stayed in memory. I did not close the tab.

When I hit the quit session after 10 seconds and immediately closed the window before the 10 seconds, it was removed from memory after the timeout.

When I hit the quit session after 10 seconds and waited till it went offline, then closed the window, it was removed from memory after the timeout.

So from this it appears that if the tab with the app is not closed it remains in memory. I wonder if there’s a way around that.

Apps won’t quit if sessions can’t be released. Are you storing references to the sessions or any pages or controls anywhere?

The test app is very simple. Download Alex’s app.


I have instituted your suggestions and all my apps now close as they should.