Refactored logic for closing single panel panels