Charles,
The usual trick in Access is to use the On Close event of a switchboard
or other form that stays open the whole time, if one exists, otherwise
employ a dummy, hidden form just for the purpose. Now, whichever way the
user closes the app (normally, that is, not by killing it through the
task manager or pulling the plug!) the form is forced to close, and so
the code is forced to run.
HTH,
Nikos