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

# destroy

> Disconnects from the SIP server, ends calls, and releases all client resources.

Disconnects from the SIP server, ends any active call, and releases all resources. This method calls `disconnect()`, then releases the internal resources of the client, clears the cached configuration, and removes all event listeners. Call this method when the client is no longer needed, for example, on page unload. If you call it more than once, the later calls do nothing. After you destroy the client, you can't reuse the instance. If you call `connect()` on it, the call fails with `Client has been destroyed`.

## Signature

```typescript theme={null}
await client.destroy();
```

## Parameters

None.

## Returns

`Promise<void>`

## Throws

An error if the cleanup process fails. The error messages start with `Failed to destroy client:`.

## Example

```typescript theme={null}
await client.destroy();
console.log('Client destroyed');
```

### Cleanup on Page Unload

```typescript theme={null}
window.addEventListener('beforeunload', () => {
  void client.destroy().catch(() => {
    // Ignore errors during page unload
  });
});
```

## More Information

* [disconnect](https://docs-classic.cognigy.com/click-to-call/sdk/api-reference/disconnect.md)
* [endCall](https://docs-classic.cognigy.com/click-to-call/sdk/api-reference/end-call.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.