IIRC, the script doesn't actually die when the user hits STOP on their Web browser; I'm not aware of any mechanism to inform the script of this. Instead, when the script tries to send data back to the user, it sees that the socket has been closed, and receives a SIGPIPE. I believe that installing a signal handler for this signal will allow you to detect when this has happened:
$SIG{PIPE} = sub { die "Connection closed while processing!\n" }