Gracefully handle interrupts and broken pipes