Signal handlers for better cleanup on exit.

SIGINT and SIGTERM will now cause the message buffer to flush and
summary messages to be sent before exiting.

(Not exactly sure about those signals in particular, but going with this
for now.)