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

# instance.end_session

> Close the session for one conversation when you know it has ended, so the platform can finalise the turn instead of waiting.

<Note>
  Requires `maximem-synap` 0.5.1 or newer (Python) and
  `@maximem/synap-js-sdk` 0.5.1 or newer (JS). Earlier versions do not
  have this method, and 0.5.0 loses events sent immediately after
  `listen()`.
</Note>

<CodeGroup>
  ```python Python theme={null}
  await sdk.instance.end_session(conversation_id)
  ```

  ```typescript TypeScript theme={null}
  await sdk.instance.end_session(conversationId)
  ```
</CodeGroup>

<Note>
  Optional. The SDK opens a session on the first event for a conversation and closes every open session when you call [`stop_listening`](/sdk-reference/instance/stop-listening). Call this only when a conversation ends and your process keeps running.
</Note>

A session start is what makes the platform warm the cache before your agent's first fetch. A session end is what finalises the turn that was in progress: the record for a turn is written when the *next* user message arrives, and the last turn of a conversation has no next one.

Call it when you know a conversation is over and the process lives on: a voice call hangs up, a chat window closes, a support case is resolved. Without it, the platform waits for the conversation to go quiet and releases the state on its own, which is correct but later.

## Parameters

<ParamField path="conversation_id" type="string" required>
  The conversation whose session should be closed. Closing one the SDK never opened is a no-op.
</ParamField>

## Returns

Returns `None`.

## Example

<CodeGroup>
  ```python Python theme={null}
  try:
      await run_the_call(conversation_id)
  finally:
      await sdk.instance.end_session(conversation_id)
  ```

  ```typescript TypeScript theme={null}
  try {
    await runTheCall(conversationId);
  } finally {
    await sdk.instance.end_session(conversationId);
  }
  ```
</CodeGroup>

## See also

* [instance.stop\_listening](/sdk-reference/instance/stop-listening): ends every open session and closes the stream.
* [Event delivery](/concepts/event-delivery): what happens to events around a close.
