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

# destroy()

> Destroy a Daily call object and release all associated resources.

`destroy()`

✓ Prebuilt✓ Custom

Destroys the call object and frees all associated resources. After `destroy()` completes, [`isDestroyed()`](https://docs.daily.co/reference/daily-js/instance-methods/is-destroyed) returns `true` and any further method calls on the instance will throw an error.

If the call is still active when `destroy()` is called, it will leave the call automatically before releasing resources — so you can call `destroy()` directly without a prior `leave()`. Call [`leave()`](https://docs.daily.co/reference/daily-js/instance-methods/leave) instead when you want to end the current session but reuse the call object for a future `join()` or want access to the call object's state before destroying it.

> [!WARNING]
>
> By default, if you attempt to create a new call object without first destroying the old one, the factory method will throw an error to prevent event handling conflicts. You must explicitly opt in to multiple-instance mode if you want to create more than one call object. See the [Multiple Instances](https://docs.daily.co/docs/daily-js/guides/multi-instance.md) guide for details.

## Return value

Returns a `Promise<void>` that resolves once all resources have been released.

## Example

```javascript theme={null}
// When the user is completely done with the call
async function endSession() {
  await call.leave();
  await call.destroy();
  callRef.current = null;
}

// Or listen for the event to clean up references
call.on('call-instance-destroyed', () => {
  callRef.current = null;
});
```

## See also

> [card] Methods
>
> * [leave()](https://docs.daily.co/reference/daily-js/instance-methods/leave.md)
> * [isDestroyed()](https://docs.daily.co/reference/daily-js/instance-methods/is-destroyed.md)

> [card] Events
>
> * [call-instance-destroyed](https://docs.daily.co/reference/daily-js/events/lifecycle-events.md#call-instance-destroyed)
> * [left-meeting](https://docs.daily.co/reference/daily-js/events/lifecycle-events.md#left-meeting)

> [card] Guides
>
> * [Introduction](https://docs.daily.co/docs/daily-js/introduction.md)
> * [Multiple instances](https://docs.daily.co/docs/daily-js/guides/multi-instance.md)


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