title: Run custom code when MFC app is terminated: d'tor or WM_CLOSE?
body: <p>I have a dialog-based MFC application which needs to stop Windows Wifi service in order to run correctly, but I want to enable it again when my application exits.</p>
  
  <p>So I thought I'd put the code that restarts the service in the destructor of the main dialog class.</p>
  
  <p>Now it has come to my attention that others put their code which should be run during program termination into a <code>WM_CLOSE</code> message handler.</p>
  
  <p>Both ways seem to work, but I would like to know if there are downsides to either way.</p>