Added an event to signal threads to return immediately.

The main thread should handle KeyboardInterrupt by setting off the
event. This will cause threads to return at the earliest opportunity. The
main thread should then raise the exception again or exit.