First you must:
import subprocess
To turn off your Windows computer:
subprocess.call(["shutdown", "/s"])
To restart a Windows computer
subprocess.call(["shutdown", "/r"])
To exit a Windows PC:
subprocess.call(["shutdown", "/l "])
To turn off a Windows computer after 900 s:
subprocess.call(["shutdown", "/s", "/t", "900"])
To abort the shutdown, because there is no good reason to shut down the computer using a Python script, you simply copied the code from stackoverflow:
subprocess.call(["shutdown", "/a "])
I just tried these function calls in Python 3.5. Firstly, I donโt think that this has changed since Python 2.7, and secondly: this is 2016, so I think you made the transition after you asked this question.
Johan source share