Ensuring a nice clean application quit experience



This is sort of an addendum to my previous post entitled: "Restrict FE
application to one user at a time".

My preferred design is to have a table with a single row that contains
the network name of the person currently connected to the database.
The existence of the row will serve a) to allow the system to bump any
other user who wishes to connect, and b) to inform such users of the
name of the currently logged-on user.

However, at the end of the session, it is VITAL that the row is
deleted from the table, so that the next time someone tries to
connect, if there is no-one connected, they can then take control of
the system.

Obviously, I can have a button on a switchboard somewhere called
"Exit" and do the clean-up just prior to Application.Quit.

However, is there any way of trapping the user pressing the
"Close" (X) button, or ALT+F4, or whatever, and ensuring that clean-up
is always achieved?

Thanks as usual

Edward

.