Enhance window close logic to always leave at least one window open.