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

# Disconnect from the Sandbox Instance

> Gracefully close the WebSocket connection and clean up sandbox resources using the Python SDK.

## `disconnect()`

The `disconnect()` method gracefully terminates your active sandbox session by closing the WebSocket connection and releasing all associated resources. This ensures that all running processes are stopped, the session is closed cleanly, and the container is freed up for reuse.

***

### `async disconnect() -> None`

**Description:**\
Gracefully terminates your active sandbox session and releases all underlying resources.

***

**Parameters:**\
*None*

***

**Returns:**\
`None`: Resolves when disconnection and cleanup are complete.

***

### **Example**

```python theme={null}
import asyncio
from fermion_sandbox import Sandbox

async def main():
    # Initialize and create a new sandbox
    sandbox = Sandbox(api_key="your-api-key")
    await sandbox.create(should_backup_filesystem=False)

    # Perform your tasks
    result = await sandbox.run_command(cmd="python3", args=["--version"])
    print("Python version:", result.stdout)

    # Always clean up when finished
    await sandbox.disconnect()
    print("Sandbox disconnected successfully.")

asyncio.run(main())
```
