Bug 996988 - use different method to wait for window closure, r=jaws

--HG--
extra : rebase_source : cfb78153229e5722609e10e9e4a417659590c28a