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

# Wendung.destroy(): Fully shut down the SDK instance

> Stop the flush timer, remove lifecycle listeners, and attempt a final flush. After destroy(), call init() again before using any other SDK method.

Call `Wendung.destroy()` to shut down the SDK. It stops the flush timer, removes the `visibilitychange` and `pagehide` listeners, and, if the queue is non-empty, fires one final fire-and-forget flush of at most one batch; any remaining events are lost. Afterwards every SDK method throws `[Wendung] Call .init() first` until [`init()`](/api-reference/init) runs again. Most useful for test cleanup and micro-frontends that mount and unmount the SDK repeatedly.

```typescript theme={null}
Wendung.destroy(): void
```

## Parameters

None.

## Returns

`void`

## Examples

### React cleanup in useEffect

```typescript theme={null}
useEffect(() => {
  Wendung.init({
    apiKey: 'pk_your_publishable_key',
  })

  return () => {
    Wendung.destroy()
  }
}, [])
```

### Test suite teardown

```typescript theme={null}
afterEach(() => {
  Wendung.destroy()
})
```

<Note>
  The final flush is not awaited and sends at most one batch. To reliably drain the whole queue first, call [`sendBeacon()`](/api-reference/send-beacon):

  ```ts theme={null}
    await Wendung.sendBeacon()
    Wendung.destroy()
  ```
</Note>


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