Come dice la documentazione,
To shut down or restart the system, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege. For more information, see Running with Special Privileges.
Examples
For an example, see How to Shut Down the System.