title: Detect when console application is closing/killed?
body: <p>I wanted to make a safe exit for my console application that will be running on linux using mono but I can't find a solution to detect wether a signal was sent to it or the user pressed ctrl+c.</p>
  
  <p>On windows there is the kernel function SetConsoleCtrlHandler which does the job but that doesnt work on mono.</p>
  
  <p>How do I get a closing event on my console application to safe exit it ?</p>