Close popup windows instead of leaving broken windows open