Wow I had a lot of trouble getting the game’s tab to close, but beside that a fun and challenging concept!
My answer got deleted when I decided to make a video of it xD So in short, I get the hint about Escape (from itch itself I think), but it doesn’t work.
In the video it sadly doesnt show my mouseclicks, I try to MMB-click on the tab to close it, then left-click “+” to open new tab. In menu “close tab” luckily works.
https://riidom.eu/img/mouse-trap.mp4
But, Vivaldi does a lot with its UI (that is why I use it:) ), and it may not occur anywhere else, so if it’s hard to reproduce and fix, just don’t bother:)
Generally, I like your way of doing it; that I don’t accidentally get the right-click menu showing up while playing or similar things.