# Terminals and the background process

> How the background process runs every terminal and agent, keeps their screens, and keeps them running when the app closes.

Source: https://hivemind.griiken.com/guide/background-process/

Every terminal and agent runs in the
<Tooltip tip="The hive process that keeps terminals and agents running while the app is closed or upgrading." cta="Glossary" href="https://hivemind.griiken.com/guide/glossary/#background-process">background process</Tooltip>,
not in the window. The window only shows them. So closing the app, or updating it, stops nothing
unless you choose **Stop everything** as you quit.

<AgentPrompt description="Paste this into your coding agent to check the background process and what it runs." page="background-process">{`
Check the Hivemind background process on this computer. Do not change anything.

1. Run \`hive daemon status\` and tell me whether it runs.
2. Run \`hive ps\` and list the sessions it keeps, with their folders.
3. If the app is open, run \`hive ctl agents --json\` and match each agent to its session.
Tell me anything that runs with no tile, and any tile whose program has stopped.
`}</AgentPrompt>

![Diagram: From an agent to its tile](https://hivemind.griiken.com/guide/images/terminal-bytes.svg)

- **Agent program** → **background process**: what it prints. Your keys go the other way.
- Background process → **desktop app**: the output, live. The app draws it in the tile.
- Desktop app → background process: attach. The screen is replayed first, then output goes on live.
- Background process → **saved screens**: a copy of each screen on disk, kept 30 days.

## What is kept [#what-is-kept]

| When | What happens |
|---|---|
| You quit (⌘Q on a Mac, Ctrl+Q elsewhere, or closing the last window) while something runs | The app asks: **Keep them running**, **Stop everything** or **Cancel**. With nothing running it quits at once. |
| You quit and choose Keep them running | Terminals and agents keep running. |
| You quit and choose Stop everything | The background process stops, as `hive daemon stop` does. Each session's screen is saved, and the next start brings it back: agents that can resume continue their conversation. Agents on other machines keep running. |
| The background process restarts, or the computer reboots | Agents that can resume continue their conversation; others start fresh. Screens replay from disk. |
| You close a tile (×) | Its program ends. |
| You put an agent to sleep | Its program ends. Its tile keeps its name and conversation, with **Resume**. |

Tick **Don't ask again** in that question to keep your choice. Change it back in
Settings → About and updates → **When you quit while agents run**. **Quit and stop agents**, in the
Open Recent menu (Ctrl+R), stops everything without asking. A quit started by an update, by
`hive`, or by any program rather than you never asks and stops nothing.

## It also works out agent states [#it-also-works-out-agent-states]

Each agent's hooks and screen reach the background process, which decides the agent's state.
See [Agent states](https://hivemind.griiken.com/guide/agent-states/).

## Without the app [#without-the-app]

On a computer without the app, `hive daemon start` runs the same background process.
[Machines and hosts](https://hivemind.griiken.com/guide/remote-machines/) use this.

<LastValidated />
