http://www.perlmonks.org?node_id=965528


in reply to Exiting batch-started Perl script on WinXP shutdown

Shouldn't the script be receiving a signal when windows shuts down?

Using %SIG to set an appropriate action (cleanup; exit 0) might be the simplest way to go about this.