Here is the code to shutdown Windows. The necessary privilege for this operation is required on NT based systems.
; Built with Pelles Macro Assembler, Version 6.50.0
; Code running on Windows NT based systems
include ShutdownWindows.inc
.data
SE_SHUTDOWN_NAME_ db 'SeShutdownPrivilege',0
.code
start:
invoke GetShutdownPrivileges
invoke ExitWindowsEx,EWX_FORCE or EWX_SHUTDOWN,0
invoke ExitProcess,0
GetShutdownPrivileges PROC USES esi
LOCAL TokenPriv:TOKEN_PRIVILEGES
LOCAL hToken:DWORD
invoke GetCurrentProcess
lea ecx,hToken
invoke OpenProcessToken,eax,\
TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,\
ecx
lea esi,TokenPriv
invoke LookupPrivilegeValue,0,ADDR SE_SHUTDOWN_NAME_,\
ADDR TOKEN_PRIVILEGES.Privileges.Luid[esi]
mov TOKEN_PRIVILEGES.PrivilegeCount[esi],1
mov TOKEN_PRIVILEGES.Privileges.Attributes[esi],SE_PRIVILEGE_ENABLED
invoke AdjustTokenPrivileges,hToken,0,ADDR TokenPriv,0,0,0
ret
GetShutdownPrivileges ENDP
END start