I understood that.

It’s fairly normal to treat context menus as modals within their parent window. Not universal, but my feeling (which I don’t trust here) is that it has been generally preferred for quite some time. I think this has also become a stronger custom as popovers have become more common, and pure context menus have become less common. It then makes sense to formalise on that pattern. And then applying the modal-closing behaviour across all windows makes sense, even if it’s not the only reasonable option and you’d prefer not.