win32api.ExitWindowsEx
ExitWindowsEx(flags, reserved)
either logs off the current user, shuts down the system, or shuts down and restarts the system.
Parameters
Comments
It sends the WM_QUERYENDSESSION message to all applications to determine if they can be terminated.
Win32 API References