in reply to Re: cleanup a cancelled CGI script
in thread cleanup a cancelled CGI script

If you take the following approach in addition, you've got a nice way to handle those issues and others as well.

eval { do_stuff( ... ); 1; } or cleanup( ... )