win32api.ExitWindowsEx

ExitWindowsEx(flags, reserved)

either logs off the current user, shuts down the system, or shuts down and restarts the system.

Parameters

flags : int

The shutdown operation

reserved=0 : int

Comments

It sends the WM_QUERYENDSESSION message to all applications to determine if they can be terminated.

Win32 API References

Search for AbortSystemShutdown at msdn, google or google groups.