title: Console application not waiting on async delay?
body: <p>I wanted to add a delay to my server when disposing so that users could actually read the shutdown message, and I couldn't do it with thread sleep as it would freeze the whole game.</p>
  
  <p>I decided to change my functionality to use an async task, but it seems like its just closing instantly, and not even disposing which is a real feature kill.</p>
  
  <p>First, I check for a key input that tells me to shutdown or reboot...</p>
  
  <pre><code>var rebootAfterClose = false;
  
  while (true)
  {
      var input = Console.ReadKey();
  
      if (input.Key == ConsoleKey.C &amp;&amp; input.Modifiers == ConsoleModifiers.Control)
      {
          break;
      }
  
      if (input.Key != ConsoleKey.R || input.Modifiers != ConsoleModifiers.Control)
      {
          continue;
      }
  
      rebootAfterClose = true;
      break;
  }
  
  Server?.Stop(rebootAfterClose);
  </code></pre>
  
  <p>I then have the code that actually shuts down</p>
  
  <pre><code>public async Task Stop(bool restart)
  {
      var shutdownMessage = PlusEnvironment.GetLanguageManager().TryGetValue("server.shutdown.message");
      var shutdownPacket = new BroadcastMessageAlertComposer(shutdownMessage);
  
      Program.Server.BaseHandler.PlayerHandler.SendPacketToPlayers(shutdownPacket);
  
      await Task.Delay(5000);
  
      // TODO: Start the process if restart = true
  
      Dispose();
  }
  
  public void Dispose()
  {
      if (Disposing)
      {
          return;
      }
  
      Disposing = true;
  
      Console.Clear();
      Console.WriteLine();
      Console.Title = "Server is shutting down...";
  
      Logger.Warn("Server is shutting down...");
  
      BaseHandler.PlayerHandler.Dispose();
      ConsoleUpdater.Dispose();
      SocketHandler.Dispose();
  
      PlusEnvironment.OnShutDown();
  
      Thread.Sleep(2000);
  
      Environment.Exit(0);
  }
  </code></pre>