Added logic and tests for closing the menu