title: Should I process WM_ENDSESSION, WM_QUERYENDSESSION, both or neither?
body: <p>If a system is trying to shut down, an app can block this shutdown by overriding <code>OnQueryEndSession()</code> and returning <code>FALSE</code>. Surely that means <code>WM_ENDSESSION</code> is the only definitive message to respond to regarding shutdown.</p>
  
  <p>On the other hand, the top answer to <a href="https://stackoverflow.com/questions/5734644/problem-with-wm-endsession-message">this question</a> quotes no less than Raymond Chen as saying that responding to <code>WM_ENDSESSION</code> is essentially pointless. So this is confusing.</p>
  
  <p>Is there some kind of "best practice" principles to apply in deciding which of these messages (if any) one should respond to for doing what kinds of application shutdown work?</p>
  
  <p>In particular, if neither message is handled, will a shutdown process cause an application to be closed as if the user had closed the application manually (e.g. click on red X close button)?</p>