Au contraire, die is working just fine. die is intended
to be used for error/exception handling only, so that is why
your webserver is throwing up a 500 error. Use
exit to come to a graceful stop.
BTW, Are you using the handy
use CGI::Carp qw(fatalsToBrowser);