Allow switching to another window when current window is closed

Closed windows are currently handled within the context of the block, but not if a window is closed and then referenced later.

The current implementation also assumes only 2 browsers (which, granted, is probably 99.99% of the time).

The initial conditional on line 54/55 can be removed if the desired behavior is to always select the initial window; either way the current behavior is to throw an exception.