Why not just close perp if a second window is opened then close the second window?