Remove interaction page race condition

If a new interaction page pops up very quickly, before Selenium has
seen that the old page has disappeared, the wait for the dialog to
disappear does not get triggered, leading to a timeout.

This commit rewrites the code so close detection depends on the element
directly, so a new interaction cannot cause problems