Catch Ctrl+C. Use buffered logging again.

SIGINT needs to be handled since deferred functions don't get called
when quitting due to a Ctrl+c.

Buffered logging is disabled in debug mode so that the messages will
appear right away.