# libtmux.Session.kill

- **Module:** libtmux.Session
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/session.py#L664
- **Page:** https://libtmux.org/reference/py/libtmux-session-kill/

```
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``.

## Parameters

- `self`
- `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.

## Example

Kill a session:

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

## Example

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

## Example

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

## Example

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

## Example

Kill all sessions except the current one:

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

## Example

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

## Example

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

## Example

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

## Example

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

## Example

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