# LibTmux.Server.stop/2

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/lib/libtmux/server.ex#L372
- **Page:** https://libtmux.org/en/elixir/pr-173/reference/libtmux-server-stop-2/

```
stop(server, options \\ [])
@spec stop(t(), [{:timeout, 1..600_000}]) ::
        :ok | {:error, LibTmux.Error.t()}
```

Stops a server that `start/1` created and removes its directory.

Sends [`kill-server`](/en/tmux/latest/manual/kill-server/), waits until the native helper proves that the daemon
has exited, and removes the directory. Stopping a server
that already stopped returns `:ok`. If the daemon still answers when
`:timeout` (5000 ms by default) ends, or the directory cannot be removed,
it returns `{:error, error}` and keeps the directory; call it again to
retry.

Any process holding the retired descriptor from `start/1` can call
`stop/2` again and receive `:ok`. A descriptor built by `new/1` returns
`{:error, error}` with kind `:not_owned`, even for the same socket.

## Parameters

- `server` (`t()`)
- `options` (`[{:timeout, 1..600_000}]`)
  Default: `[]`.
