title: How to run a function before PC shuts down with python?
body: <p>Is it possible to run a function in Python before the PC shuts down? Or lets say while it is shutting down?</p>
  
  <p>Maybe using os module, or something else.</p>
  
  <p>So let's say I have this function and I want to run it while PC is shutting down:</p>
  
  <pre><code>def onShutDown():
      # lets say send an email
  </code></pre>
  
  <p>BTW: I know how to send an email with smtplib so that is not the problem here.</p>
  
  <p>Thank you!</p>