> ## Documentation Index
> Fetch the complete documentation index at: https://tbd-6fc993ce-hypeship-scraperly-link.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"}',
  )
  ```
</CodeGroup>

## Via CLI

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