Handle KeyboardInterrupt exception