> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bqto.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Cleanup

> What a bqto session deletes when it ends, what can stay behind after a crash, how to remove it, and how to find who created a bastion.

A session deletes its bastion when it ends. A session ends in these cases:

* You press Ctrl-C.
* You close the terminal.
* bqto gets a `kill`.
* The command after `--` exits.
* `--duration` runs out.

If the delete fails, bqto says so on stderr and exits with code 1. If the command after `--` already
exited with a code other than 0, bqto keeps that code.

## What can stay behind

| What | Where | How to remove it |
| - | - | - |
| A bastion, if bqto was killed with `kill -9`, the laptop died, or the delete failed, and the deadline has not passed yet | The project, labeled `bqto=session` | Run `gcloud compute instances list --filter=labels.bqto=session`, then `gcloud compute instances delete NAME --zone ZONE` |
| The SSH key that gcloud made for the tunnel | `~/.ssh/google_compute_engine` and `.pub` | Delete them. gcloud makes new ones when it needs them |
| The host key and the certificate of a bastion whose session was killed | `~/.ssh/google_compute_known_hosts`, `~/.ssh/google_compute_engine_cert/` | Delete the `compute.ID` lines and the file. A session that ends normally removes its own |

To check that no bastion is left in a project, run:

```sh theme={null}
gcloud compute instances list --filter=labels.bqto=session
```

## Who created a bastion

The name of a bastion is `bqto-` plus eight random characters. The name does not say who ran the command.
This is on purpose. If it did, anyone who can list instances would see the email of a colleague.

The Admin Activity audit logs tell you who created a bastion.
[Security](https://docs.bqto.dev/reference/security.md#the-audit-trail) has the queries.

## Uninstall

[Install](https://docs.bqto.dev/install.md#uninstall) shows how to remove bqto.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.