handle KeyboardInterrupt exception