I don't see anything obvious (and this seems like it should be something obvious). However, you do have die inside your exit subroutine a couple times, which could conceivably be causing trouble, since you're already in END. (You can't stack ENDs up)