To detect and prevent shutdown the computer I use very simple program. It has only one form and one private procedure like below:
TForm3 = class(TForm) priva
I usually run "shutdown -a" command. You can do the same from your code to interrupt Windows from shutdown.
Regards