in reply to cleanup a cancelled CGI script

On Unix, the CGI script is attached to the web server through a pipe or socket. A write to a closed pipe or socket produces a SIGPIP signale that by default kills your program. It is possible to safely cleanup by adding a signale handler.
$SIG{PIPE} = sub { die "Pipe error"; }
By turning the signal into a die, the error is logged and END blocks will be run.