How to exit Herdr: detach, close or stop without losing work

By

Updated

Tagged: AI

Learn the difference between detaching, closing a pane, stopping a session, and exiting Herdr without accidentally killing running work.

If you want to leave Herdr without losing what’s running, detach from it by pressing ctrl+b, letting go, and pressing q. That drops you back to your normal shell while the Herdr server keeps your panes, coding agents, tests, and dev servers alive in the background. Closing your terminal window has the same effect because the server owns those processes rather than the window itself.

When you’re ready to jump back in, run:

herdr

Detaching behaves very differently from closing a pane, closing a workspace, or stopping the Herdr server, even though the commands sound similar.

The quick answer

What you wantAction
Leave Herdr and keep everything runningctrl+b, then q
Return to the default sessionherdr
Close one shell paneRun exit in that shell
Close a pane by IDherdr pane close PANE_ID
Close one tab and its panesherdr tab close TAB_ID
Close one workspace and its tabsherdr workspace close WORKSPACE_ID
Stop the default session and all pane processesherdr server stop
Stop one named sessionherdr session stop NAME
Delete a stopped named sessionherdr session delete NAME

When you’re not sure which command you need, detach with ctrl+b, q so nothing gets killed by accident.

How do I quit Herdr completely?

Run herdr server stop to shut down the default Herdr server and terminate every process running inside its panes, including coding agents, tests, and dev servers. Make sure you’ve saved everything first. The next time you run herdr, it brings back your workspaces and layout with fresh shells in each pane. If you’re using a named session, run herdr session stop NAME instead.

Detach without stopping the work

Herdr splits its work between a server and a client. The server owns the pseudo-terminals and running processes, while the client is just the interface drawn inside your terminal window. Detaching disconnects the client and leaves the server alone.

To detach, press these two keys one after the other:

ctrl+b, then q

Hold Control and press b, let go of both keys, and then press q.

Whenever you want to come back, reattach with:

herdr

You’ll land right back in the same live panes with your coding agents, servers, and tests still running. This is what I use at the end of the day or right before I close an SSH connection.

What if I close the terminal window?

Since the Herdr server owns your processes, closing Windows Terminal, Ghostty, iTerm2, Kitty, or any other terminal window while attached only drops the client. The server keeps running, and the same thing happens if an SSH connection dies mid-session.

Just open a new terminal and reattach:

herdr

I still prefer detaching explicitly when I can, since it drops you back into your shell cleanly instead of tearing down the terminal window.

Exit one shell

To close a normal shell pane, run this inside the shell:

exit

You can also press ctrl+d on an empty prompt. Either way, once that shell exits, Herdr closes the pane it lived in.

Watch out if a foreground program is running in that pane. Typing exit sends those characters to the program instead of the shell, so stop the program first with ctrl+c for a dev server or the app’s own quit command for an editor or interactive agent. Be careful with ctrl+d there too, because it sends an end-of-file signal and every program reacts to that differently.

Close a pane from the CLI

Start by listing the active panes to grab the live ID you need:

herdr pane list

Then close that specific pane (using the real ID from herdr pane list instead of the example ID below):

herdr pane close w1:p2

Herdr stops whatever process is running inside the pane and removes it from your layout. Because that kills unsaved editor buffers, coding agents, or dev servers on the spot, it’s worth reading the pane contents first if you’re unsure what’s in there:

herdr pane read w1:p2 \
  --source recent-unwrapped \
  --lines 80

Passing explicit IDs like this is also much safer in scripts and agent workflows than guessing which pane happens to have focus.

Close a tab

To see what tabs are open, list them first:

herdr tab list

Then close the one you want to get rid of:

herdr tab close w1:t2

Keep in mind that closing a tab takes down every pane inside it, which might include an agent, a test watcher, a dev server, and a log tail all at once. Check the tab and its panes before closing it:

herdr pane list --workspace w1

If you only mean to remove a single pane, stick with herdr pane close.

Close a workspace

First, list your workspaces to get the ID:

herdr workspace list

Then close the workspace you’re done with:

herdr workspace close w2

Since a workspace holds tabs and those tabs hold panes, closing it stops every process running inside that workspace. Only do this when you’re truly finished with a project context.

If you just want to jump over to another project without shutting anything down, switch workspaces instead:

herdr workspace focus w1

You can also press ctrl+b, then w and pick a workspace straight from the UI.

Stop the default Herdr session

Stopping the server is the destructive option, so don’t use it when you just mean to detach:

herdr server stop

This shuts down the default Herdr server and kills every pane process it owns. Save it for when you deliberately want to end the session, restart after an update, or debug a server issue.

Before you stop the server, run through a quick check:

  • save editor changes
  • finish or stop tests
  • shut down development servers cleanly
  • let coding agents finish or record their session state
  • check every workspace for important processes

When you run herdr again after a full stop, it restores your saved workspace shape (workspaces, tabs, panes, directories, layout, and focus), while normal panes come back as fresh shells instead of reviving old processes. Supported coding agents can pick up their conversations again, provided a current official Herdr integration saved their native session IDs beforehand. You can inspect your installed integrations with:

herdr integration status

If an integration is out of date, reinstall it using herdr integration install <agent>. Without an up-to-date integration, that agent pane reopens as a plain shell in the saved directory.

Live handoff vs stop/restart

Detaching leaves the current server untouched, while stopping and starting rebuilds your layout after all the processes have exited. Live handoff sits in between: it swaps in a new Herdr server and asks the old one to pass over its live panes so your running processes stay alive. You’ll mainly use it for updates or remote attach flows where you want a fresh server without a cold restart:

herdr update --handoff
herdr --remote workbox --handoff

Running plain herdr update installs the new client and leaves compatible servers running, and plain herdr --remote workbox does the same for a compatible remote server. Pass --handoff when you want to swap out a supported running server without dropping its panes.

One caveat: herdr update --handoff only works when Herdr manages its own updates. If you installed it through Homebrew, mise, or Nix, herdr update is disabled because your package manager handles upgrades, so handoff isn’t available there. Handoff is also still experimental and opt-in, so if something goes wrong, you’ll fall back to a regular stop and restart that ends your pane processes.

Pane screen history

When you do a full server restart, Herdr can replay recent terminal output back into your restored panes. That screen history gives you back what was visible on screen so you have context, though the old process itself is gone.

It’s turned off by default since terminal output often holds secrets, tokens, prompts, and sensitive command results. If you want to enable it, treat Herdr’s config and session directory with the same care as your shell history:

[experimental]
pane_history = true

Once it’s on, Herdr writes that scrollback to session-history.json right next to session.json.

Stop and delete a named session

Each named session runs as its own independent Herdr server. To see what’s currently defined, list them:

herdr session list

You can stop a specific one without touching anything else:

herdr session stop work

That shuts down the pane processes inside that named session. If you attach to it again later, Herdr rebuilds the saved layout for you:

herdr session attach work

When you’re done with a stopped session and want to wipe its saved state too, delete it:

herdr session delete work

Herdr keeps stopping and deleting separate so you can shut down a live runtime while keeping its layout around, and only remove the session from the list and discard its saved state when you’re sure you won’t need it again.

Detach from a remote session

The exact same detach shortcut works over SSH. Connect to your server and launch Herdr:

ssh you@server
herdr

When you’re ready to leave, press ctrl+b, then q to drop back to the remote shell, and close your SSH session cleanly:

exit

Your remote Herdr server and all of its panes stay running on the machine. Next time you SSH in, reattach to pick up where you left off:

ssh you@server
herdr

This is the same workflow I rely on when connecting to Herdr from a phone.

Detach from direct terminal attach

On supported Unix systems, you can attach your current terminal straight to a single agent or pane:

herdr agent attach reviewer

To leave that direct stream, use the same detach sequence:

ctrl+b, then q

And if the program inside that pane needs a literal ctrl+b, send it like this:

ctrl+b, then ctrl+b

Native Windows doesn’t support direct terminal attach right now.

Detach does not survive every kind of failure

Detaching keeps your original server and processes alive, which is as resilient as a terminal session gets, but plenty of everyday events will still stop your work:

  • the Herdr server is stopped
  • the machine reboots
  • the operating system kills the process
  • the user logs out in an environment that terminates user services
  • the process exits on its own

Once the server restarts after any of those, Herdr can bring back your layout and, if enabled, your recent scrollback, while resuming a coding agent conversation still depends on having a current Herdr integration installed for that agent.

If you’re still comparing multiplexers, I put Herdr side by side with cmux, the native Mac app, in Herdr vs cmux, and rounded up more options in Herdr alternatives.

I pressed the wrong keys

ctrl+b q does nothing

Make sure you press ctrl+b, release both keys, and then press q rather than holding all three keys at once. If that still doesn’t work, your config might override the prefix or detach key. You can check your active bindings with:

ctrl+b, then ?

All the default bindings are listed in Herdr keyboard shortcuts.

I stopped the server

Start Herdr back up to restore your saved layout:

herdr

From there, check which coding agents resumed and which panes came back as fresh shells, then restart your dev servers and tests manually.

A pane disappeared

When a shell or foreground program exits, Herdr can close the pane along with it. Closed pane IDs aren’t reused, so open a new pane and start the command again.

I only wanted to hide a pane

Switch to another tab or workspace, or zoom a different pane instead. Closing a pane kills its process, so don’t use it just to get a pane out of your way.

The rule to remember

Default to ctrl+b, then q whenever you want to step away and come back to your running work. Only reach for close, stop, or delete when you mean to end processes or clear out saved session state.

If you want to see every state transition in detail, check the official table in Herdr’s session state and restore guide.

Want me to talk about your product? You can sponsor this site.

Related posts about ai: