@ad777,
I assume the idea is to run this script at startup, as you haven't stated anything on how to use it, and the _call() function will become active when a Windows message is received to Shutdown/Restart, but you never want to have a close loop without any form of pausing in it, so this script will probably max out at least 1 CPU core 100% of the time.
I've also provided a Tidy.exe option in the Full version of SciTE4AutoIt3, so would recommend to always run in before posting code here, so all looks readable.
Adapted version:
#include <AutoItConstants.au3>
OnAutoItExitRegister("_shutdown")
#cs
0 = Natural closing.
1 = close by Exit function.
2 = close by clicking on exit of the systray.
3 = close by user logoff.
4 = close by Windows shutdown Or Restart(same)
#ce
While 1
Sleep(100)
WEnd
Func _shutdown()
If @exitMethod = 4 Then
MsgBox(0, '', 'exit by shurdown||Restart') ;;exit by shutdown Or Restart
EndIf
EndFunc ;==>_shutdown
Merry Christmas.