Error Control C Exit 572 (0x23C): How to Fix it

To address this issue, you need to handle the error properly

Reading time icon 2 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team. Read more

ERROR_CONTROL_C_EXIT

When developing you may encounter the following code: ERROR_CONTROL_C_EXIT. Many users don’t know what this code represents, so let’s dive deeper and see what it does.

How can I fix ERROR_CONTROL_C_EXIT?

1. Modify the code

  1. Open your code.
  2. Next, use the following code
    import signal
    import sys
    def handle_sigint(signum, frame):
    print("\nCTRL+C detected. Performing cleanup...")
        # Add any cleanup logic here
      sys.exit(0)  # Exit gracefully

    signal.signal(signal.SIGINT, handle_sigint)

    while True:
        print("Running... Press CTRL+C to stop.")

    handle signit
  3. Save changes.

2. Log the interruption

  1. Open your code.
  2. Adjust it like this:
    import signal
    import sys
    import logging

    logging.basicConfig(filename='app.log', level=logging.INFO)
    def handle_sigint(signum, frame):
        logging.info("Application terminated by CTRL+C")
        sys.exit(0)

    signal.signal(signal.SIGINT, handle_sigint)

    while True:
        print("Running... Press CTRL+C to stop.")

    log interuption
  3. Save changes.

3. Use proper cleanup

  1. Open your code again.
  2. Modify it so it uses this logic:
    import signal
    import sys

    file = open('example.txt', 'w')

    def handle_sigint(signum, frame):
        print("Closing file and exiting...")
        file.close()
        sys.exit(0)

    signal.signal(signal.SIGINT, handle_sigint)

    while True:
        file.write("Writing data...\n")

    cleanup code
  3. Save changes.

4. Additional tips

  1. Set a proper restart policy if the application terminates.
  2. Handle logging of unexpected exits.
  3. Inform users that this keyboard shortcut exits most command line applications.

In most cases, ERROR_CONTROL_C_EXIT doesn’t need additional handling, since it’s a regular occurrence when a user uses a keyboard shortcut to exit the code.

Keep in mind that this error sometimes comes with the following message: 572 (0x23C) {Application Exit by CTRL+C} The application terminated as a result of a CTRL+C.

This is just one of many issues you can encounter, and recently we wrote about Subprocess-exited-with-error and Kernel Stack Locked At Exit, so don’t miss them for more information.

More about the topics: error

User forum

0 messages