Fix handling exceptions while KeyboardInterrupt.