Sounds like the program is done by the time control-c has been hit, but your operating system hasn't finished showing you all the output. .

Answer from Andy V on Stack Overflow
Discussions

KeyboardInterrupt and SystemExit in exception groups should be considered for Python's exit code - Ideas - Discussions on Python.org
I’ll start with an example program to try to show what I think is a pitfall. Then I’ll be more specific. ▶ Example program I think that a KeyboardInterrupt or a SystemExit within an exception group should behave as if those exceptions weren’t in an exception group with regards to the ... More on discuss.python.org
🌐 discuss.python.org
0
March 3, 2025
KeyboardInterrupt ignored on Windows
Hello, with the sample below after hitting Ctrl+C, the script exits on Linux but nothing happens on Windows. Linux python 3.8.6 python-engineio 3.13.2 python-socketio 4.6.0 Windows python 3.8.5/3.9... More on github.com
🌐 github.com
15
November 26, 2020
python - KeyboardInterrupt not raised or caught in the case of broad Exception - Stack Overflow
Run it, wait for a while, press Ctrl+C, the KeyboardInterrupt exception will not be caught. ... Python installs a small number of signal handlers by default: SIGPIPE is ignored (so write errors on pipes and sockets can be reported as ordinary Python exceptions) and SIGINT is translated into ... More on stackoverflow.com
🌐 stackoverflow.com
How can I add an keyboard interrupt to a program?
How are you running this? A normal terminal does this by default. More on reddit.com
🌐 r/learnpython
20
1
December 3, 2018
🌐
Medium
medium.com › @proficientPython › fixing-keyboardinterrupt-error-in-python-3-67c93b15c5c2
Fixing KeyboardInterrupt Error in Python 3 | by proficientPython.py | Medium
September 22, 2022 - The KeyboardInterrupt error occurs when you try to exit a Python program using the Ctrl+C key combination. This can be frustrating, but there are ways to handle it like a pro.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-catch-a-keyboardinterrupt-in-python
How To Catch A Keyboardinterrupt in Python - GeeksforGeeks
July 23, 2025 - Catching KeyboardInterrupt in Python is essential for handling user interruptions gracefully, especially in programs with time-consuming operations. By using a try-except block, you can effectively catch and handle KeyboardInterrupt, ensuring that your programs exit in a controlled manner.
🌐
Python.org
discuss.python.org › ideas
KeyboardInterrupt and SystemExit in exception groups should be considered for Python's exit code - Ideas - Discussions on Python.org
March 3, 2025 - I’ll start with an example program to try to show what I think is a pitfall. Then I’ll be more specific. ▶ Example program I think that a KeyboardInterrupt or a SystemExit within an exception group should behave as if those exceptions weren’t in an exception group with regards to the ...
🌐
GitHub
github.com › miguelgrinberg › python-socketio › issues › 570
KeyboardInterrupt ignored on Windows · Issue #570 · miguelgrinberg/python-socketio
November 26, 2020 - KeyboardInterrupt ignored on Windows#570 · Copy link · Assignees · Labels · bug · asmarcz · opened · on Nov 26, 2020 · Issue body actions · Hello, with the sample below after hitting Ctrl+C, the script exits on Linux but nothing happens on Windows. Linux python 3.8.6 python-engineio 3.13.2 python-socketio 4.6.0 Windows python 3.8.5/3.9.0 neither is working python-engineio 3.13.2 python-socketio 4.6.0 ·
Author   asmarcz
Find elsewhere
🌐
Python
bugs.python.org › issue26531
Issue 26531: KeyboardInterrupt while in input() not catchable on Windows 10 - Python tracker
March 10, 2016 - This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/70718
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
Not catching KeyboardInterrupt - Raspberry Pi Forums
I'm just a rookie at Python, but I'd do it like this: The interrupt should be set outside the loop. Create a function for the LED switching and have the interrupt call it. Place the loop inside the "try-except" block. I haven't actually tested this, but it should work.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-resolve-issue-threading-ignores-keyboardinterrupt-exception-in-python
How To Resolve Issue " Threading Ignores Keyboardinterrupt Exception" In Python? - GeeksforGeeks
July 23, 2025 - However, when working with threads, there can be issues related to KeyboardInterrupt exceptions being ignored. The KeyboardInterrupt exception is commonly used to interrupt a running Python program, especially when it is stuck in an infinite loop or waiting for user input. The issue of "Threading Ignores KeyboardInterrupt Exception" arises when a KeyboardInterrupt exception is not properly handled in threaded programs.
🌐
Real Python
realpython.com › ref › builtin-exceptions › keyboardinterrupt
KeyboardInterrupt | Python’s Built-in Exceptions – Real Python
>>> while True: ... print("This will run forever unless interrupted") ... This will run forever unless interrupted This will run forever unless interrupted This will run forever unless interrupted This will run forever unless interrupted Traceback (most recent call last): ... KeyboardInterrupt
🌐
w3resource
w3resource.com › python-exercises › python-exception-handling-exercise-7.php
Python program for Handling KeyboardInterrupt
Write a Python program that prompts the user to input a number and handles a KeyboardInterrupt exception if the user cancels the input. ... Raised when the user hits the interrupt key (normally Control-C or Delete). During execution, a check for interrupts is made regularly. The exception inherits from BaseException so as to not be accidentally caught by code that catches Exception and thus prevent the interpreter from exiting.
🌐
CSDN
devpress.csdn.net › python › 630461a0c67703293080c207.html
Why doesn't this python keyboard interrupt work? (in pycharm)_python_Mangs-Python
August 23, 2022 - From your screen shot it appears that you are running this code in an IDE. The thing about IDEs is that they are not quite the same as running normally, especially when it comes to handling of keyboard characters. The way you press ctrl-c, your IDE thinks you want to copy text. The python program never sees the character.
🌐
Lightrun
lightrun.com › answers › lightning-ai-lightning-keyboardinterrupt-signal-does-not-raise-keyboardinterrupt-error
KeyboardInterrupt Signal does not raise ...
Debug Daily provides real-world solutions to common developer problems. Find answers to GitHub Actions errors, React Native issues, Python bugs, and more. Sponsored by Lightrun.
🌐
Developer Community
developercommunity.visualstudio.com › idea › 520545 › keyboard-interrupt-for-python-interpreter.html
keyboard interrupt for python interpreter
Skip to main content · Visual Studio · Guidelines Problems Suggestions Code of Conduct · Downloads · Visual Studio IDE Visual Studio Code Azure DevOps Team Foundation Server Accounts and Subscriptions · Subscriber Access · Microsoft Security Azure Dynamics 365 Microsoft 365 Microsoft ...
🌐
Django
code.djangoproject.com › ticket › 16682
#16682 (KeyboardInterrupt not handled properly in transaction aborting) – Django
Problem in django.db.transacti... has value. But if raise KeyboardInterrupt manualy from code it's work ok. Possible solution: use exc_type and exc_value in exiting function · I use python 2.6.6 ·...
🌐
JetBrains
youtrack.jetbrains.com › issue › PY-45016 › Python-Console-nested-Keyboard-Interrupt-handling
Python Console (nested) Keyboard Interrupt handling
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
Delft Stack
delftstack.com › home › howto › python › keyboard interrupt python
How to Catch the KeyboardInterrupt Error in Python | Delft Stack
February 2, 2024 - The KeyboardInterrupt error occurs ... or by interrupting the kernel in the case of Jupyter Notebook. To prevent the unintended use of KeyboardInterrupt that often occurs, we can use exception handling in Python....