Thanks to Chris and Joseph for responding so quickly with the END { } suggestion. Seems to be just what I'm looking for. Problem is that it doesn't seem to want to work! :( Simple example: --- #!perl -w sub END { open LOG, ">>LOG.TXT"; print LOG "END executed!\n"; close LOG; } print "Enter a command: "; $command = <STDIN>; print $command; --- Now, if you run the above script (or save it as a runtime application and run that) and then do a Command-Q on it *instead* of typing a command, you'll probably get the following flash across your screen: # Callback called exit. # END failed--cleanup aborted. (You might need to redirect STDERR to a file if you're on a fast machine.) NOTHING gets written to the log file. The behaviour I am looking for is that if the script/application is prematurely terminated by the user (or the system), then the line "END executed" is appended to the log file. What am I missing? Henry. # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org