W3cubDocs

/Web APIs

CloseWatcher: destroy() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The destroy() method of the CloseWatcher interface deactivates the close watcher. This is intended to be called if the relevant UI element is torn down in some other way than being closed.

After being deactivated, this CloseWatcher will no longer receive cancel or close events, and it will be possible to create new independent CloseWatcher instances.

Syntax

destroy()

Parameters

None.

Return value

None (undefined).

Examples

>

Using the destroy() method

Use the destroy() method to dispose of the watcher instance for cleanup.

watcher.destroy();

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
destroy 126 126 preview 112 No 126 No 83 No 28.0 126 No

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CloseWatcher/destroy