As an example:
My python script is running
And sometimes I forgot my script is running then I accidentally shut down my computer
Is there anyways to let my script quickly throw an exception and perform some other movements before system get shutdown?