window: fix leak of all detached windows
If a tab is detached from one window, forming a new window, then the new window is leaked. The most visible symptom is audio from a video continues playing when the window is closed.
Fixes #2130 (closed) (hopefully fully, this time)