WM_ENDSESSION

This message is sent to tell an application that has responded nonzero to a WM_QUERYENDSESSION message whether the session is actually being ended.

Parameter Description  

wParam Specifies whether or not the session is being ended. It is nonzero if the session is being ended. Otherwise, it is zero.  
lParam Is not used.  

Comments

If the wParam parameter is nonzero, Windows can terminate any time after all applications have returned from processing this message. Consequently, an application should perform all tasks required for termination before returning from this message.

The application does not need to call the DestroyWindow or PostQuitMessage function when the session is being ended.