You can use `return` in the main workflow to stop a workflow's execution. You
can also finish a workflow by simply completing the final step (assuming that
the step doesn't jump to another).

A workflow's execution stops when one of the following occurs:

- An [error is raised and not caught](https://docs.cloud.google.com/workflows/docs/reference/syntax/catching-errors)
- After all steps have been executed
- When the keywords `end` or `return` are used in the main workflow

## Use `end`

In the main workflow, you can use `next: end` to stop a workflow's execution if
you don't need to return a value. A main workflow that executes a `next: end`
step completes with `null` as the result.

In a subworkflow, you can use `next: end` in a step to make it the last step in
the subworkflow and return `null`. It does not need to be in a separate step
(unlike `return`) and can be used in any step. When using either `next: end` or
`return`, control is returned to the calling subworkflow.

### YAML

```yaml
  - STEP_NAME:
      ...
      next: end
  
```

### JSON

```json
  [
    {
      "STEP_NAME": {
        ...
        "next": "end"
      }
    }
  ]
    
```

## Use `return`

Use `return` to stop a workflow's execution and return a value, variable, or
expression:

### YAML

```yaml
  - STEP_NAME:
      ...
      return: ${VARIABLE}
  
```

### JSON

```json
  [
    {
      "STEP_NAME": {
        ...
        "return": "${VARIABLE}"
      }
    }
  ]
    
```