Open UI Widget should get closed as I click to a button

I have a menu that opens when the user is on that page. So when the user clicks on another menu, the open menu needs to close and the other menu opens. So far I’ve only managed to get the menu to open when clicked. I can’t get the other open menu to close. I have these 4 buttons as I click each button the other menu should get close