Close a definition from outside the canvas?

From outside the canvas (like a Human UI interface for example), I’d like to have a “Close” button that would actually close the definition.
I have found nothing of the sort in plugins or scripts so far, and I have no idea how to script this myself, unfortunately. (2.3 KB)

It’s a kind of magic…

Thanks Dani !