# libtmux.Window.kill

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

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

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

Kill :class:`Window`.

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

## Examples

Kill a window:

```python
>>> window_1 = session.new_window()
```

```python
>>> window_1 in session.windows
True
```

```python
>>> window_1.kill()
```

```python
>>> window_1 not in session.windows
True
```

Kill all windows except the current one:

```python
>>> one_window_to_rule_them_all = session.new_window()
```

```python
>>> other_windows = session.new_window(
...     ), session.new_window()
```

```python
>>> all([w in session.windows for w in other_windows])
True
```

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

```python
>>> all([w not in session.windows for w in other_windows])
True
```

```python
>>> one_window_to_rule_them_all in session.windows
True
```

## Parameters

- `all_except` (`bool | None`)

## In other ports

### Close a window

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