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

# phone_session_end

> Close a session and cancel its remaining tasks.

Closes a session and cancels every remaining task in it. Idempotent - ending an already-ended session is safe.

## Parameters

<ParamField body="session_id" type="string" required>
  The session to close.
</ParamField>

## Behavior

* **Cancels remaining tasks.** Any pending, running, or paused task in the
  session completes with `terminal: "stopped_by_user"`.
* **Call it only when the entire workflow is finished.** A successful task
  completion does not require ending the session - reuse the same
  `session_id` for related follow-up tasks instead.
* Do not reuse a session after ending it; subsequent task calls fail with
  `session_not_found_or_inactive`. Start fresh with
  [`phone_session_start`](/api-reference/tools/phone-session-start) or let
  [`phone_run_task`](/api-reference/tools/phone-run-task) create one.

<Tip>
  To stop one runaway task without losing the workflow, use
  [`phone_task_cancel`](/api-reference/tools/phone-task-cancel) - it keeps the
  session open.
</Tip>

## Related

* [`phone_task_cancel`](/api-reference/tools/phone-task-cancel) - cancel one task, keep the session
* [`phone_session_start`](/api-reference/tools/phone-session-start) - open the next workflow
