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

# ubx terminate

> Destroy all resources in the stack (runs pulumi destroy / terraform destroy).

`ubx terminate` tears down a deployed stack. It checks for a prior apply record (from `ubx ship`) to reuse the compiled artifact. If no record exists, it runs the full compile pipeline first.

## Usage

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx terminate [path] [flags]
```

## Flags

| Flag      | Description                  |
| --------- | ---------------------------- |
| `--force` | Skip the confirmation prompt |

## Examples

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/xcl.json"]}}
ubx terminate                        # destroy current stack (prompts)
ubx terminate --force                # destroy without prompting
ubx terminate ./networking           # destroy a specific directory
```

## What happens

1. **Check apply record** — reads `.ubx/last-apply.json`
   * If found: reuses the `artifact_uri` and `plugin_name` (skips compile)
   * If not found: runs the full XCL pipeline (compile → typecheck → IR → plugin Compile)
2. **Confirmation** — prompts with resource count unless `--force`
3. **Plugin Destroy** — invokes plugin's `Destroy` RPC, streams progress events

## Progress output

```
  ◆ Stack       networking (from last apply)
  ◆ Destroy     running pulumi destroy…

  - aws:ec2:Subnet    networking-public-1b    (3.1s)
  - aws:ec2:Subnet    networking-public-1a    (3.2s)
  - aws:ec2:Vpc       networking-vpc          (4.8s)

  done (11.1s)  ·  3 destroyed
```

## Safety

Without `--force`, ubx shows:

```
  This will destroy all resources in stack "networking".

  Destroy? [y/N]
```

Type `y` to proceed. Any other input cancels.

## After termination

The apply record (`.ubx/last-apply.json`) is not automatically removed. Run `ubx state list` to verify the stack is empty.

## Exit codes

| Code | Meaning                                         |
| ---- | ----------------------------------------------- |
| `0`  | All resources destroyed                         |
| `1`  | Compile/typecheck/destroy error; user cancelled |
