One of my Delphi XE2 programs, when running and idle, 'prevents Windows shutdown'. This is not the case with most of my applications and I need to resolve it. On XP, Windows silently fails to close; on Win7 the dialog shows my application preventing shutdown.
Unlike the similar questions here, the program is single-threaded, I am not using the tray, and I have temporarily disconnected the OnCloseQuery and FormClose events in the main form and the one subsidiary form that had them. In normal use the program closes cleanly and no trace of it remains in Process Explorer.
I have experimemtally added WM_QueryEndSession and WM_EndSession handlers which write a log message to the Windows Event log. On a test Windows shutdown, only the former fires, with Wparam and Lparam both zero.
I would be most grateful for any ideas on what could be causing this, or for how to investigate it further. I am reluctant to try a call to Halt on the WM_QueryEndSession without knowing what is going on.