[Recreator Required] No tab with id: 1662

There has to be an answer to this bug.
It is opening and focusing on a new tab when a link is clicked.
Then when the tab is automatically closed it shows this error, “No tab with id: 1662.”

Update: So I think I’ve found the source of the problem.
The problem is, when I open a new tab and the script selects it (selectWindow - tab=1), the new tab is now selected and in focus.
The problem is that the tabs are closed automatically by another script in another extension.
So when the tab is closed, the waitForElementPresent command is still running on the tab that was closed and so this crash.
So my question is, is there a way to know when the secondary tab is closed by the user/otherwise and then continue afterwards, i.e. wait for a secondary tab to close?
Is there any way to do this?

Can you please add a screencast for this issue? I tried to recreate it, but in my test case, when I manually close a tab opened by UI.Vision, the macro continues in the now active tab. This is the way it should be. And it seems for some reason it does not work in your case.