title: how to catch program shutdown to release resources?
body: <p>In my program i'm using</p>
  
  <pre><code>logWriter = File.CreateText(logFileName);
  </code></pre>
  
  <p>to store logs.</p>
  
  <p>Should I call logWriter.Close() and where? Should it be <code>finalizer</code> or something?</p>