properly close secondary windows