title: Application does not exit when an error happening on systemd
body: <p>So I developed an application using <code>.net-core</code>, I run this software on a linux machine as a <code>daemon</code> service using <code>systemd</code>. Now the problem is that when an error happen in the app, it enters in a "limbo", infact each activity of the application is logged using <code>Console.WriteLine</code> and I can see this log typing that command on linux machine: <code>journalctl -fu app.service</code>.</p>
  
  <p>When the error happen the log doesn't write anything, but at the same time the application keep running and this is really strange because I setup the service with the following configuration:</p>
  
  <pre><code>[Unit]
  Description = Daemon service
  
  [Service]
  ExecStart = /usr/bin/dotnet /home/my username/Desktop/publish/SimpleApp.dll
  WorkingDirectory= /home/foo/Desktop/publish
  Restart = always
  RestartSec = 3
  
  [Install]
  WantedBy = multi-user.target
  </code></pre>
  
  <p>as you can see the <code>Restart = always</code> should restart the app when an error is raised. When an exception is raised the method <code>Error()</code> write the error inside a file and then kill the software in the following way:</p>
  
  <pre><code>public void Error(Exception ex)
  {
     File.WriteAllText("error.txt", ex.ToString());
     Environment.Exit(1); 
  }
  </code></pre>
  
  <p>Must be some problem on <code>Environment.Exit</code> with the <code>Linux</code> environment, or I did something wrong calling <code>Environment.Exit</code>. There are other ways to close an application like this which run as system service?</p>
  
  <p>Thanks</p>