Closes a window and all the tabs inside it, given the window's ID.

This is an asynchronous function that returns a Promise.


var removing =
  windowId        // integer


integer. ID of the window to close.

Return value

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.

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic support Yes No45 No Yes


When the user clicks a browser action's icon, close the window in which the icon was clicked:

function onRemoved() {
  console.log(`Removed window`);

function onError(error) {
  console.log(`Error: ${error}`);

browser.browserAction.onClicked.addListener((tab) => {

  var removing =;
  removing.then(onRemoved, onError);


Example extensions


This API is based on Chromium's API. This documentation is derived from windows.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

Contributors to this page: wbamberg, Makyen, chrisdavidmills
Last updated by: wbamberg,