Hi,
Just to add my thoughts here.
Disclaimer: I am not a Python expert and last time I used Windows was 4 years ago.
From what I know is that Windows does not automatically terminate all child processes when the CMD window is closed, especially if the parent process is still running. However, the behavior can vary depending on how the child processes are created and how they are tied to the parent process.
Python’s __del__
method is not executed when the CMD window is closed. Forcibly closing the CMD window kills the Python interpreter abruptly, leaving no chance for cleanup or finalization routines. This is also why child processes remain as "zombies" in Task Manager — they weren’t properly terminated.
In contrast, when you use CTRL+C, Python’s signal module can catch the interruption (e.g., through SIGINT) and handle cleanup gracefully before the program exits.
The bottom line is that I am not that sure we should be expecting the proper termination of all children processes by closing the CMD on Windows 10 (and possibly other platforms). I'd suggest to try CTRL+C instead of closing CMD window.
Thanks