Skip to main content
macOSbeginner

How to Reopen a Closed Terminal Window on macOS (and Recover What Was Running)

Accidentally closed a Terminal or iTerm2 window on macOS? There's no 'reopen closed tab' shortcut, but you can restore windows on relaunch, recover commands from shell history, and resume long-running CLI tools. Step-by-step for 2026.

7 min readUpdated June 2026

Want us to handle this for you?

Get expert help →

There is no Cmd+Shift+T to reopen a closed window in Apple's Terminal.app — that shortcut works in browsers, not in Terminal. But "I closed the window" rarely means "I lost the work." The window is just a view onto a shell, and the two things you actually care about — the commands you ran and the program that was running — are usually recoverable from elsewhere. This guide covers Terminal.app, iTerm2, recovering your command history, and resuming long-lived CLI tools.

Closed a window that had Claude Code running in it? Your conversation is safe on disk regardless of the terminal. See How to recover an accidentally closed Claude Code session, then come back here to reopen the window itself.

Quick Reference

GoalHow
Reopen windows after quitting TerminalSystem Settings → Desktop & Dock → uncheck Close windows when quitting an application, then Cmd+Q and relaunch
Recover commands you typedNew window → Up arrow or Ctrl+R (reverse search); file is ~/.zsh_history
Reopen the last closed iTerm2 windowiTerm2 restores sessions on relaunch (see iTerm2 settings below)
Keep a session alive across closesRun it inside tmux or screen, reattach with tmux attach
Resume a long-running tool's stateUse that tool's own resume feature (e.g. Claude Code's claude --continue)

Terminal.app: What You Can and Can't Get Back

You can't reopen a single closed window directly

If you press Cmd+W (close window) or Cmd+Q (quit) and the window is gone, Terminal.app offers no menu item or shortcut to bring that exact window back on demand. There's no "Recently Closed" list like Safari's.

You can make windows return on relaunch

macOS has a system-wide window restoration feature. When it's enabled, quitting and reopening an app restores the windows it had open:

  1. Open System Settings → Desktop & Dock.
  2. Scroll to Windows and turn off "Close windows when quitting an application."
  3. Now Cmd+Q to quit Terminal, then reopen it — your previous windows and tabs reappear.

The catch: this triggers on quitting and relaunching the whole app, not on closing one window while Terminal stays open. If you closed a single window and other Terminal windows are still open, restoration won't bring the closed one back.

Recover the commands you typed

This is usually what people actually want. Your shell records every command to a history file:

  • zsh (the macOS default since Catalina): ~/.zsh_history
  • bash: ~/.bash_history

In a fresh window:

# Step back through recent commands
# (press the Up arrow repeatedly)

# Search history interactively
# press Ctrl+R, then type part of the command

# Print the whole history
history

# Find a specific command
history | grep ssh

Important caveat for zsh: by default zsh writes history to the file when the shell exits cleanly. If the window was force-closed or the Mac crashed, the last few commands from that session may not have been flushed. To make zsh save history immediately after every command, add this to ~/.zshrc:

setopt INC_APPEND_HISTORY    # write each command as it's entered
setopt SHARE_HISTORY         # share history live across open shells

iTerm2: Better Restoration

iTerm2 restores far more than Terminal.app. By default it can reopen the sessions you had running when it last quit:

  • iTerm2 → Settings → General → Startup controls window-restoration behavior on launch.
  • Window restoration can bring back your split panes and tabs after a relaunch.
  • For deliberate recovery, save your layout with Window → Save Window Arrangement, and restore it later with Window → Restore Window Arrangement (or set it as the default arrangement so it loads on every launch).

As with Terminal, iTerm2's restoration triggers on app relaunch — it is not an undo for a single Cmd+W. The command-history recovery steps above apply identically in iTerm2.

Don't Lose It Next Time: Persistent Sessions

If you regularly run long tasks (builds, training jobs, SSH sessions, servers), put them inside a terminal multiplexer so a closed window never kills them:

# Start a named session
tmux new -s work

# ...run your long job...

# Detach by hand (session keeps running): press Ctrl+B then D
# Or just close the window — the session survives, detached

# From ANY new window, list and reattach:
tmux ls
tmux attach -t work

screen works similarly (screen -S work to start, screen -r work to reattach) and ships with macOS. With tmux/screen, closing the window only detaches you — the processes keep running and your scrollback is intact when you reattach.

Resuming Tools That Save Their Own State

Many modern CLI tools persist their state to disk and don't care that the terminal window closed. The best example is Claude Code, which writes every conversation to a transcript file under ~/.claude/projects/. Closing the window doesn't delete anything — you reopen a terminal, cd back to your project, and run:

claude --continue      # resume the most recent conversation in this directory
# or
claude --resume        # pick from a list of past sessions

The full walkthrough — including how the transcript files are organized and how to recover a session from any window — is in How to recover an accidentally closed Claude Code session.

Summary

  • macOS Terminal has no "reopen closed tab" shortcut — Cmd+Shift+T won't help.
  • Turn off "Close windows when quitting an application" to make windows return on relaunch.
  • Recover typed commands from ~/.zsh_history with the Up arrow, Ctrl+R, or history.
  • iTerm2 restores sessions and saved window arrangements on launch.
  • Use tmux/screen so a closed window never kills a long-running job.
  • Tools like Claude Code persist their own state — just relaunch and resume.

Frequently Asked Questions

Find answers to common questions

No. Apple's Terminal.app has no built-in shortcut to reopen a closed window or tab. Cmd+Shift+T does nothing in Terminal. What you can do instead is rely on macOS window restoration (which reopens windows when you quit and relaunch the whole app) and recover your typed commands from the shell history file (~/.zsh_history). iTerm2 has more complete session restoration than Terminal.app.

Closing the window kills the foreground process running in that shell (unless it was started with nohup, disown, tmux, or screen). However, the commands you typed are saved in your shell history, and any program that persists its own state to disk — like Claude Code, which writes conversation transcripts to ~/.claude/projects — can be resumed. The window is gone; the work it touched usually is not.

Open a new Terminal window and press the Up arrow to step back through recent commands, or press Ctrl+R and type part of a command to reverse-search your history. The persistent history lives in ~/.zsh_history (zsh, the macOS default) or ~/.bash_history (bash). Run history to print it. Note that zsh only flushes history to the file when the shell exits cleanly, so the very last commands from a force-closed window may be missing.

macOS has system-wide window restoration. Open System Settings > Desktop & Dock and turn OFF 'Close windows when quitting an application.' Then, when you quit Terminal (Cmd+Q) and reopen it, your windows and tabs come back. This applies on app quit-and-relaunch — it does not reopen a single window you closed with Cmd+W while the app stays open.

Run long jobs inside tmux or screen. Start a session with tmux, do your work, and if the window closes the session keeps running detached. Reattach from any new window with tmux attach. For interactive tools that persist their own history — such as Claude Code — you don't need tmux; just relaunch and use the tool's resume command (for Claude Code, claude --continue).

Need help shipping something?

Productized MVP development for founders. 9 SaaS apps shipped — yours could be next, in 6 weeks.