How to close widget using its own button

I have a little popup menu widget with some buttons that act on other objects, but I want the menu to close when I left click once on any one of the buttons on the menu widget. How can I achieve this?

Does this do it?


Perfect, thank you