Hide tooltip on click outside of the tooltip

Hi,
I have a component that contains a tooltip that is revealed on click event. Now, I would like to hide it when user clicks anywhere on the page outside of this tooltip. Any tips on how to achieve it? Thank you in advance.

Maciej