fixed bug with closing and re-opening popup windows