Detecting computer/program shutdown in Python?
<p>I have a Python script that runs in a loop regularly making adjustments to my lighting system.  When I shut down my computer, I'd like my script to detect that, and turn off the lights altogether.</p>

<p>How do I detect my computer beginning to shut down in Python?</p>

<p>Or, assuming Windows sends Python a "time to shut down" notice, how do I intercept that to kill my lights and exit the loop?</p>
