Get to know MDN better
Closes a window and all the tabs inside it, given the window's ID.
This is an asynchronous function that returns a Promise.
integer. ID of the window to close.
A Promise that will be fulfilled with no arguments when the window has been closed. If any error occurs, the promise will be rejected with an error message.
When the user clicks a browser action's icon, close the window in which the icon was clicked:
Close the current, e.g., popup, window when the user clicks a button on the page:
In Firefox, the same could be achieved with the .allowScriptsToClose window creation property and window.close().
Enable JavaScript to view this browser compatibility table.
Note: This API is based on Chromium's chrome.windows API. This documentation is derived from windows.json in the Chromium code.
This page was last modified on Jul 17, 2025 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.