How do I remove a widget when i click at a random place?

You can look at InputComponent, there is an event for touch, but you can also use it with a mouse click. So when that fires you trace stuff under the cursor, and if it doesn’t hit your mesh you remove that widget.