The CloseWatcher API landed in Firefox 149, making it easy to listen for platform-specific 'dismiss' signals. Here's how it works:
@axeleroy in cases where you use close watcher, you still need to destroy the close watcher.
I guess closeWatcher?.destroy(); closeSidebar(); would do it.