How do I terminate a window in tmux? Like the Ctrlak shortcut in screen, where Ctrla is the prefix.
11 Answers
try Prefix
+ &
if you have
bind q killp
in your .tmux.conf
, you can press Prefix
+ q to kill the window too, only if there is only one panel in that window.
if you have multiple panes and want to kill the whole window at once use killw
instead of killp
in your config.
the default of Prefix above is Ctrl+b, so to terminate window by default you can use Ctrl+b &
-
11This works fine: `Ctrl+b &`, note, that you have to confirm with `y` to really kill the current window incluning all panes in that window. You will get be placed inside the window that you used last before that. – rubo77 Sep 01 '16 at 05:02
-
3It's worth noting that by default `Prefix` + `q` shows pane number, so assigning `killp` to this combination will override this shortcut. – kmo Dec 05 '17 at 14:51
<Prefix>
&
for killing a window
<Prefix>
x
for killing a pane
If there is only one pane (i.e. the window is not split into multiple panes, <Prefix>
x
would kill the window)
As always iterated, <Prefix>
is generally CTRL+b
. (I think for beginner questions, we can just say CTRL+b
all the time, and not talk about prefix at all, but anyway :) )

- 3,208
- 2
- 21
- 26
-
I couldn't kill just the pane with
x, only with – Pablo Bianchi Feb 04 '19 at 02:20:, then typing [`respawn-pane -k`](https://unix.stackexchange.com/a/88393/209677).
Generally:
tmux kill-window -t window-number
So for example, if you are in window 1 and you want to kill window 9:
tmux kill-window -t 9

- 8,029
- 10
- 53
- 79

- 1,917
- 3
- 19
- 19
-
3This. (Thank you so much by the way!) If done remotely where tmux is running in some other terminal, one can do `INFO=$(tmux new-window -P notepad)` followed by `tmux kill-window -t $INFO`. – John May 16 '18 at 21:13
-
2To kill a specific pane `tmux kill-pane -t 1`, where 1 is the pane number – Levon May 21 '21 at 03:42
For me solution looks like:
ctrl+b q
to show pane numbers.ctrl+b x
to kill pane.
Killing last pane will kill window.

- 8,946
- 8
- 66
- 102
-
3This is the best solution when you've just finished a process inside a tmux window. – Philip Kirkbride May 18 '16 at 02:52
-
2`Killing last pane will kill window`. Does not work for me? I'm using mac – Andy Aldo Apr 09 '19 at 04:18
-
-
1`ctrl+b x` will always ask me whether I want to kill pane 0 even if I'm on pane 5. What am I doing wrong? – Cornelius Roemer Nov 03 '21 at 23:32
-
@CorneliusRoemer If your prefix is `ctrl+b` then to kill specific window (if you are on window 5). `prefix + &` will kill the windows 5 instead of windows 0. – anuragp Oct 09 '22 at 07:37
Kent's response fully answered your question, however if you are looking to change tmux's configuration to be similar to GNU Screen, here's a tmux.conf that I've used to accomplish this:
# Prefix key
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Keys
bind k confirm kill-window
bind K confirm kill-server
bind % split-window -h
bind : split-window -v
bind < resize-pane -L 1
bind > resize-pane -R 1
bind - resize-pane -D 1
bind + resize-pane -U 1
bind . command-prompt
bind a last-window
bind space command-prompt -p index "select-window"
bind r source-file ~/.tmux.conf
# Options
set -g bell-action none
set -g set-titles on
set -g set-titles-string "tmux (#I:#W)"
set -g base-index 1
set -g status-left ""
set -g status-left-attr bold
set -g status-right "tmux"
set -g pane-active-border-bg black
set -g pane-active-border-fg black
set -g default-terminal "screen-256color"
# Window options
setw -g monitor-activity off
setw -g automatic-rename off
# Colors
setw -g window-status-current-fg colour191
set -g status-bg default
set -g status-fg white
set -g message-bg default
set -g message-fg colour191

- 1,450
- 2
- 12
- 12
-
16This is overly verbose and doesn't indicate where the question is answered – rodorgas Jun 24 '20 at 14:00
If you just want to do it once, without adding a shortcut, you can always type
<prefix>
:
kill-window
<enter>

- 8,029
- 10
- 53
- 79

- 16,580
- 18
- 81
- 143
ctrl + d
kills a window in linux terminal, also works in tmux.
This is kind of a approach.

- 427
- 4
- 11
-
3Note that this shortcut just means "end of data". It only works if the currently running process in the tmux pane accepts this signal and terminates itself upon receiving it (e.g. as bash does). Because there is no process around in the pane, it gets closed by tmux. Does not work in all cases. – nyi Feb 26 '18 at 16:39
-
-
2This is OK if there is a running shell in the window, but if there is just a frozen application, something more brutal is needed. Nikolay Fominyh's answer works fine. – oz1cz Jan 23 '19 at 14:04
-
-
-
This detached from my entire session and put me back into bash. Was able to reconnect to the session though. – StuperUser Nov 24 '22 at 13:46
Lot's of different ways to do this, but my favorite is simply typing 'exit' on the bash prompt.

- 985
- 5
- 10
-
3This presumes bash is running in the window. The window I wanted to kill which led me to this page is the list of tmux commands - that has no shell to exit. – Michael Campbell Jan 16 '14 at 00:51
-
1If you were looking at the list of commands displayed by
+?, you can leave that by pressing q or – Scott Centoni May 30 '14 at 17:19.
While you asked how to kill a window resp. pane, I often wouldn't want to kill it but simply to get it back to a working state (the layout of panes is of importance to me, killing a pane destroys it so I must recreate it); tmux provides the respawn
commands to that effect: respawn-pane
resp. respawn-window
. Just that people like me may find this solution here.

- 6,856
- 4
- 32
- 47
By default
<Prefix>
& for killing a window
<Prefix>
x for killing a pane
And you can add config info
vi ~/.tmux.conf
bind-key X kill-session
then
<Prefix>
X for killing a session

- 696
- 1
- 6
- 20
-
2This might come in handy for beginners. `
` by default is `Ctrl+b` which means, one first needs to press `Ctrl` and `b` buttons together and then press the mentioned key. for example for deleting a pane, you first go into command mode by Ctrl+b (i.e pressing prefix) and then pressing x on your keyboard. – Hossein Aug 03 '20 at 03:09
I can confirm following working on tmux running in ssh via Windows Command:
Copy: Press shift
, select using mouse, press Ctrl+Shift+C
Paste: Shift+Right click
No special settings were needed.

- 63,284
- 17
- 238
- 185