> ## Documentation Index
> Fetch the complete documentation index at: https://tbd-6fc993ce-hypeship-docs-website-deploy-hook.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Stopping

You can terminate an invocation that's running. This is useful for stopping automations or agents stuck in an infinite loop.

<Info>
  Terminating an invocation also destroys any browsers associated with it.
</Info>

## Via API

You can stop an invocation by setting its status to `failed`. This will cancel the invocation and mark it as terminated.

<CodeGroup>
  ```typescript Typescript/Javascript theme={null}
  import Kernel from '@onkernel/sdk';

  const kernel = new Kernel();

  const invocation = await kernel.invocations.update('invocation_id', {
    status: 'failed',
    output: JSON.stringify({ error: 'Invocation cancelled by user' }),
  });
  ```

  ```python Python theme={null}
  from kernel import Kernel

  kernel = Kernel()
  invocation = kernel.invocations.update(
      id="invocation_id",
      status="failed",
      output='{"error":"Invocation cancelled by user"}',
  )
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"

  	"github.com/kernel/kernel-go-sdk"
  )

  func main() {
  	ctx := context.Background()
  	client := kernel.NewClient()

  	invocation, err := client.Invocations.Update(ctx, "invocation_id", kernel.InvocationUpdateParams{
  		Status: kernel.InvocationUpdateParamsStatusFailed,
  		Output: kernel.String(`{"error":"Invocation cancelled by user"}`),
  	})
  	if err != nil {
  		panic(err)
  	}
  	_ = invocation
  }
  ```
</CodeGroup>

## Via CLI

Use `ctrl-c` in the terminal tab where you launched the invocation.
