When a chrome app window is closed, is it possible to detect the event? and do an action before the window is closed?
chrome.app.window.current().onClosed allows you to register an event listener for when a window is closed.