Handle KeyboardInterrupt with waiting for queue to empty.
Add exception and KeyboardInterrupt handling.
Merge