Improve focus handling to ensure we have no lingering windows open