In tmux, what many people call a “tab” is usually a window. A tmux window can contain one or more panes, so closing a tab is different from closing a pane or ending an entire tmux session. Knowing which one you want to close helps you avoid losing work in other parts of your terminal.
The quickest way to close the current tmux window is to press Ctrl-b, release the keys, and then press &. Tmux asks you to confirm before closing it. You can also use a command to close a specific window. This guide explains both approaches, how they differ from closing panes and sessions, and what to do if a window will not close.
What Does “Tab” Mean in Tmux?
Tmux does not use browser-style tabs, but its windows serve a similar purpose. Each window is a separate terminal workspace inside a tmux session. You might use one window for editing code, another for running tests, and a third for viewing logs. The window list is often displayed along the bottom of the terminal, which is why tmux windows are commonly called tabs.
A window can also be divided into panes. Panes are multiple terminal areas within the same window. Closing a pane usually leaves the window open if other panes remain. Closing a window removes that workspace and all of its panes. Ending a session is a larger action that closes every window in that session.
- Window: A tmux workspace, often described as a tab.
- Pane: A split terminal area inside a window.
- Session: A collection of windows that can remain available after you detach.
If your goal is to close just one tmux tab, you usually want to close a window—not a pane, session, or the entire tmux server.
How to Close the Current Tmux Tab with a Shortcut
By default, tmux uses Ctrl-b as its prefix key. You press the prefix first, let go, and then press the command key. To close the current window, use this sequence:
- Press
Ctrl-b. - Release both keys.
- Press
&. - Confirm the prompt if you want to proceed.
The & key is usually typed with Shift and the number 7 on a standard US keyboard. Depending on your keyboard layout, the exact key combination may differ. Tmux displays a confirmation prompt because closing a window can end running programs in its panes.
If you decide not to close the window, cancel the prompt with n or press Ctrl-c. If you confirm, tmux closes the window and switches to another available window in the session. If it was the session’s only window, the session may end as well.
Close a Tmux Window with a Command
You can close a window from the tmux command prompt or from a regular shell. The tmux command for closing a window is kill-window. When run inside tmux, it closes the current window:
Ctrl-b, then :, then type kill-window and press Enter.
You can also run the command from a shell outside tmux by specifying a target. For example:
tmux kill-window -t mysession:2
In this example, mysession is the session name and 2 is the window index. To check the names and indexes of windows, run:
tmux list-windows -t mysession
Use a specific target when you want to close a window without changing your current tmux view. Take care when using kill-window: it closes the selected window directly and may not display the same confirmation prompt as the keyboard shortcut. Check the target before running the command, especially if you have multiple sessions open.
How to Close a Tmux Pane Instead
If you only want to remove one split area and keep the rest of the window open, close the pane rather than the window. The default shortcut is Ctrl-b, followed by x. Tmux prompts you to confirm that you want to kill the active pane.
You can also type kill-pane at the tmux command prompt. To target a particular pane, use a pane target, such as tmux kill-pane -t mysession:2.1. The exact target depends on your session, window, and pane indexes.
There is an important edge case: if the pane you close is the only pane in its window, closing it also closes the window. A window needs at least one pane to remain open. If you are unsure which pane is active, check the tmux status line or use list-panes before running a targeted command.
Close a Tmux Tab by Exiting the Shell
Another way to close a window is to exit the shell running in its pane. Type exit and press Enter, or use Ctrl-d in a shell that accepts it as an end-of-file signal. If the window contains only that pane, the pane closes and the window usually disappears. If other panes remain, the window stays open.
This method is useful when you have finished working in the shell and want it to shut down normally. However, it is not the best choice if a program is still running. Exiting a shell can stop foreground work or leave you with an unexpected result. Save files and stop or finish important processes before closing the pane.
Some tmux configurations use the remain-on-exit option. With that setting enabled, a pane can remain visible after its process exits. If typing exit appears to leave an empty pane on screen, the pane may be configured to remain after the shell ends. You can still close it using the pane shortcut or a kill-pane command.
Close a Window Without Ending the Whole Session
Closing one window normally leaves the other windows in the same session open. Before closing it, you can see the available windows with Ctrl-b, followed by w, which opens tmux’s window chooser. Select a different window if you want to check that your other workspaces are still available.
If the window is the only one in the session, closing it can end that session. If you want to keep the session alive, create another window first with Ctrl-b, followed by c, or from the tmux command prompt with new-window. You can then close the window you no longer need.
To leave a session running without closing its windows, detach instead of killing anything. The default detach shortcut is Ctrl-b, followed by d. Detaching disconnects your terminal while keeping the tmux session available to reattach later with tmux attach.
Close a Tmux Session or the Entire Tmux Server
Closing a window is not the same as closing a session. To end the current session, use exit in its last shell, or run tmux kill-session with the appropriate target. For example:
tmux kill-session -t mysession
This closes every window in the specified session. Any running processes in those windows may be stopped, so confirm that you have saved your work first. If you only want to close one tab, do not use kill-session.
The command tmux kill-server is broader still: it shuts down the tmux server and ends all tmux sessions managed by that server. Use it only when you intentionally want to close everything, not as a way to remove a single window.
What If a Tmux Window Is Linked to Multiple Sessions?
Tmux can link a window into more than one session. This is an advanced feature, but it matters if you are trying to remove a window from just one session. The unlink-window command removes the window from the targeted session without necessarily destroying it everywhere. For example:
tmux unlink-window -t mysession:2
If the window is still linked to another session, it can remain available there. By contrast, kill-window is intended to kill the target window rather than simply remove one session’s link to it. When working with linked windows, list your sessions and windows first so you can confirm exactly where the window is being used.
Troubleshooting Common Tmux Close Commands
-
The shortcut does nothing: Confirm that you pressed the tmux prefix first. The default is
Ctrl-b, but your configuration may use another key, such asCtrl-a. Check your tmux configuration file for aset-option -g prefixsetting. -
You see a confirmation prompt: This is expected after the window-close shortcut. Press
yto confirm ornto cancel. -
You closed a pane but the window remains: That is normal when other panes are still open. Use the window shortcut
Ctrl-b, then&, if you mean to close the entire tab. -
The window closed, but the session is still active: The session likely has other windows. Use
Ctrl-b, thenw, or runtmux list-windowsto view them. -
A command targets the wrong window: Run
tmux list-sessionsandtmux list-windows -t session-namebefore using a targeted close command. -
A closed pane stays visible: Check whether
remain-on-exitis enabled, then close the pane explicitly if needed.
Quick Reference: Tmux Close Commands
-
Close the current window:
Ctrl-b, then&. -
Close a window with a command:
kill-window. -
Close a specific window:
tmux kill-window -t session:window. -
Close the current pane:
Ctrl-b, thenx. -
Exit the shell in a pane: Type
exitor pressCtrl-d. -
Detach without closing the session:
Ctrl-b, thend. -
Close a session:
tmux kill-session -t session-name. -
Close all tmux sessions:
tmux kill-server.
Conclusion
To close a tmux tab, close its window. With the default key bindings, press Ctrl-b and then &, and confirm when prompted. Use kill-window when you prefer a command or need to target a particular window. If you only want to remove one split, close the pane with Ctrl-b, then x; if you want to leave your work running, detach with Ctrl-b, then d.
Before using a command that kills a window or session, check its target and save any important work. Keeping the distinction between tmux windows, panes, and sessions in mind makes it much easier to close the right workspace without disrupting the rest of your terminal.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.