I had the same issue.
According to MDN documentation:
This method can only be called on windows that were opened by a script using the Window.open() method. If the window was not opened by a script, an error similar to this one appears in the console: Scripts may not close windows that were not
opened by script.
Note also that close() has no effect when called on Window objects returned by HTMLIFrameElement.contentWindow.
There's one workaround which sometimes works and sometimes not:
javascript
const closePopup = () = {
window.open('', '_parent', '');
window.close();
};
You can try if it works in your case.
P.S.
We decided to hide a close button in case if it's a Safari extension. Users can click on the extension icon or outside of the extension popup to close it.