Properly handle keyboard interrupts

This avoids printing a stack trace on interrupt and adds a place for
cleaning stuff up if necessary at any point in the future.