How to detect Windows is Closing Down / System Shutdown?

The included FrameExtension Template Jane mentions is probably the easiest.

If you want more control … Windows sends 2 messages (events). You have to subclass the frame to get them. For more info search the web for WM_QUERYENDSESSION and WM_ENDSESSION. If you answer YES your Frame will get an EVENT:CloseDown and it will send that to all Children.

WM_QUERYENDSESSION EQUATE(0011h) !Windows is asking if we would shutdown, True says YES
WM_ENDSESSION EQUATE(0016h) !Windows IS shutting down, we say YES and will get EVENT:CloseDown next

This template has the code. You can add it to an APP and generate to see the code it adds.