A few tweaks to catch keyboard interrupts / EOF