# Testing VM shutdown from another BEAM

If the code under test calls `System.stop/1`, running it in an ExUnit test stops the VM that's running the suite. Start a second Elixir VM and check its exit status from the test:

```elixir
test "the child VM shuts down cleanly" do
  {output, status} =
    System.cmd("elixir", ["--no-halt", "-e", "System.stop(0)"], stderr_to_stdout: true)

  assert status == 0, output
end
```

`--no-halt` keeps the child running after the expression returns, so it can't pass just by reaching the end of the script. In Kogen Studio's shutdown test, the child starts the daemon, sends its stop command over a Unix socket and checks the acknowledgement. ExUnit checks that the VM exited and the socket file is gone.

https://elixir.hexdocs.pm/System.html#stop/1

---

Created by: almirsarajcic
Date: November 28, 2026
URL: https://elixirdrops.net/d/EjNWh2Ms
