const STORAGE_KEYS = ["recording", "recordingTabId"]; chrome.tabs.onRemoved.addListener((tabId) => { chrome.storage.local.get(["recording", "recordingTabId"], (data) => { if (data.recording && data.recordingTabId === tabId) { chrome.storage.local.remove(STORAGE_KEYS); } }); });