This code forgets the single most recently-closed session, whether it's a tab or a window:
function forgetMostRecent(sessionInfos) {
if (!sessionInfos.length) {
console.log("No sessions found")
return;
}
let sessionInfo = sessionInfos[0];
if (sessionInfo.tab) {
browser.sessions.forgetClosedTab(sessionInfo.tab.windowId, sessionInfo.tab.sessionId);
} else {
browser.sessions.forgetClosedWindow(sessionInfo.window.sessionId);
}
}
function onError(error) {
console.log(error);
}
browser.sessions.getRecentlyClosed({maxResults: 1})
.then(forgetMostRecent, onError);