Handling KeyboardInterrupt exception