How can I make a python script that is run only through terminal (no GUI) to not quit when the red X at the top is pressed, but to assign a function to that signal which eventually would close the window and the process (something like an alert dialog on exit, but terminal based)?
Share
In general, you can use the
atexitmodule to register functions to be called on exit:Of course, the user can always force-quit your process, and you can’t do anything about that!