# libtmux.Session.kill

- **Module:** libtmux
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/38e368c11117fb4aeb2f082d552cd4f210eae06a/src/libtmux/session.py#L649
- **Page:** https://libtmux.org/en/py/stable/reference/libtmux-session-kill/

tmux command: [`kill-session`](/en/tmux/latest/manual/kill-session/)

```
libtmux.Session.kill(
    self,
    all_except: bool | None = None,
    clear: bool | None = None,
    group: bool | None = None,
) -> None
```

Kill :class:`Session`, closes linked windows and detach all clients.

[`$ tmux kill-session`](/en/tmux/latest/manual/kill-session/).

## Examples

Kill a session:

```python
>>> session_1 = server.new_session()
```

```python
>>> session_1 in server.sessions
True
```

```python
>>> session_1.kill()
```

```python
>>> session_1 not in server.sessions
True
```

Kill all sessions except the current one:

```python
>>> one_session_to_rule_them_all = server.new_session()
```

```python
>>> other_sessions = server.new_session(
...     ), server.new_session()
```

```python
>>> all([w in server.sessions for w in other_sessions])
True
```

```python
>>> one_session_to_rule_them_all.kill(all_except=True)
```

```python
>>> all([w not in server.sessions for w in other_sessions])
True
```

```python
>>> one_session_to_rule_them_all in server.sessions
True
```

## Parameters

- `all_except` (`bool | None`): Kill all sessions in server except this one.
- `clear` (`bool | None`): Clear alerts (bell, activity, or silence) in all windows.
- `group` (`bool | None`): Kill all sessions in this session's group (``-g`` flag).
Requires tmux 3.7+. If used with tmux < 3.7, a warning is issued
and the flag is ignored.

## In other ports

### End a session

- Ruby: [`LibTmux::Session#kill`](/en/ruby/latest/reference/libtmux-session-kill/) (method)
- Lua: [`libtmux.Session:kill`](/en/lua/latest/reference/libtmux-session-kill/) (method)
- TypeScript: [`session.Session.kill`](/en/ts/latest/reference/session-session-kill/) (method)
- Rust: [`session.Session.kill`](/en/rs/latest/reference/session-session-kill/) (method)
- Go: [`tmux.Session.Kill`](/en/go/latest/reference/tmux-session-kill/) (method)
- Java: [`io.github.libtmux.Session.Session.kill`](/en/java/latest/reference/io-github-libtmux-session-session-kill/) (method)
- C#: [`LibTmux.Session.KillAsync`](/en/csharp/latest/reference/libtmux-session-killasync/) (method)
- C++: [`libtmux::Session::kill`](/en/cxx/latest/reference/libtmux-session-kill/) (method)
- Swift: [`Server.kill(_:)`](/en/swift/latest/reference/server-kill(_-)/) (method)
