catch SIGINT/SIGTERM and cleanly exit

What do you think about something like this so you can cleanly kill a process without losing a queued item?  See any errors in my logic?