> ## 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

<ParamField path="None" />

## Returns

<ResponseField name="void">
  Returns a `void` operator.
</ResponseField>

## 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 title="Do you need practical examples?" icon="text-align-start" href="https://www.ibm.com/docs/SSAVQO/deploy/web_chat_agent/tutorials/tutorials_lp.html" arrow="true" cta="Learn with walk-throughs" horizontal>
  Learn how to apply the features available for embedded chat into your implementation with guidance and examples.
</Card>
