> ## Documentation Index
> Fetch the complete documentation index at: https://tbd-6fc993ce-mason-add-copy-page-to-context-menu.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 client = new Kernel({
    apiKey: 'My API Key',
  });

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

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

  client = Kernel(
      api_key="My API Key",
  )

  invocation = client.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.
