How to run a function when user presses “X” in the Python Console?

Clash Royale CLAN TAG#URR8PPPHow to run a function when user presses “X” in the Python Console?
How do I run a function when user presses "X" button on the python running console?
atexit
SIGKILL
Calling
atexit.register() as the very last line in your program is kind of pointless - you might as well just call the registered function directly, since it's going to happen immediately anyway.– jasonharper
14 mins ago
atexit.register()
Wait, that
/s means this is Windows, not POSIX, right? The rules for what Windows does on shutdown are slightly different—but it comes down to TerminateProcess if you don't respond nicely, and you can't handle/ignore/block that either, so same deal.– abarnert
13 mins ago
/s
TerminateProcess
os.system("shutdown /s /t 1") is working but it's not working when I'm calling it from register() func. And yes its windows
– crdw
9 mins ago
Ok, I think this question could be changed.
– crdw
5 mins ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Is the shutdown SIGKILLing your process? If so, there's nothing
atexitcan do. There's not even anything you could do in C code.SIGKILLcan't be handled, blocked, or ignored; the kernel just kills the signalled process without running any further code.– abarnert
15 mins ago