Using a Callback function

You can use a callback
functionA function that is passed as an argument in
another function. Callback functions must be user-written
functions. (with the OnEvent function) to perform housekeeping tasks
before the system shuts down. You would normally call OnEvent() in the main startup function (defined
with the [Code]Startup parameter).
Each time a Shutdown() call is
made, the callback function is run.