title: how to know the application is shutting down
body: <p>There is a WPF application.</p>
  
  <p>i want to log when the application is closed.</p>
  
  <p>but i cannot modify the application (some restriction, just because business).</p>
  
  <p>So i create an invisible form component live inside the existing application, add as a dll library, so the existing application do not need to be modified.</p>
  
  <p>but the issue is, how can my invisible component know the application is shutting down?</p>
  
  <p>is there some function or event handler i can use?</p>
  
  <p>Solution:</p>
  
  <p>there are some event can do that,</p>
  
  <p>UnLoaded
  Closing
  Closed</p>
  
  <p>all these three events will be fired when the main windows is going to be closed.</p>
  
  <p>Problem solved</p>