Fix issue if multiple windows are open