I want to do something when terminate the python script on windows.
# coding:utf-8 import ctypes import os def set_exit_handler(): def on_exit(event):
You should use the atexit module, which allows you to register exit hooks without using os specific function calls.