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

# destroy()

Destroys the web chat instance and removes it from the page, cleaning up all associated resources and event listeners.

## Syntax

```javascript theme={null}
instance.destroy();
```

## Parameters

**None**

## Returns

**void**

Returns a `void` operator.

## Examples

The following examples show different ways to destroy the chat instance:

```javascript theme={null}
// Destroy chat when user logs out
const handleLogout = () => {
    instance.destroy();
    // Perform other logout actions
};

// Destroy chat when navigating away
window.addEventListener('beforeunload', () => {
    instance.destroy();
});
```

> [card] [Do you need practical examples?](https://www.ibm.com/docs/SSAVQO/deploy/web_chat_agent/tutorials/tutorials_lp.html)
>
> Learn how to apply the features available for embedded chat into your implementation with guidance and examples.
