title: atexit, exit delegate in c#
body: <p>In c++ there is a function called <a href="http://www.cplusplus.com/reference/clibrary/cstdlib/atexit/" rel="noreferrer">atexit</a> where you can register functions which should be run when the system exits. Are there any similar events in C#?</p>
  
  <p>UPDATE:
  The AppDomain.ProcessExit doesn't seem to catch Ctrl-C or Ctrl-Break. Anyone knows anything about that?</p>