title: Shutdown or Reboot a WSL session from inside the WSL session
body: <p>I would like to be able to reboot WSL sessions. To do so is a little awkward as WSL does not use systemd so we cannot use <code>reboot</code>. Within a WSL session, we can run any Windows executable:</p>
  <pre><code>boss@Asus: ~ $ wsl.exe -l -v
    NAME            STATE           VERSION
  * Ubuntu-20.04    Running         2
    fedoraremix     Stopped         1
    Alpine          Stopped         1
    Ubuntu          Stopped         1
  </code></pre>
  <p>Therefore, we can use <code>wsl.exe</code> (you have to make sure to always add <code>.exe</code> when calling Windows commands or they will not work) to shutdown the currently running WSL session <code>wsl.exe -t Ubuntu-20.03</code>, but the problem is that I don't know the session name.</p>
  <p>When we are inside a WSL session, <code>hostname</code> is something different, and so I don't know how to find the name of the currently running session that I am inside (maybe a Windows process command that tells me what process I am running from??).</p>
  <p>Ideally, I would like a command to equate to a reboot. I guess this would have to look something like:</p>
  <ul>
  <li>Run an asynchronous command that will initiate a new session 5-10 seconds in the future to allow the previous session to fully shutdown (and that will not terminate when this session is terminated).</li>
  <li>Terminate the currently running session with <code>wsl.exe -t &lt;my found name&gt;</code>.</li>
  <li>A few seconds later, the new session will start up.</li>
  </ul>