9951 explained code solutions for 126 technologies


chrome-extensionHow to close browser from background script


chrome.tabs.query({}, function (tabs) {
  for (var i = 0; i < tabs.length; i++) {
    chrome.tabs.remove(tabs[i].id);
  }
});ctrl + c
chrome.tabs

tabs manipulation API

.query({}

select all tabs

function (tabs)

define handler to execute for found tabs (all tabs in our case)

chrome.tabs.remove

close specified tab by id