Close plugin automatically?

I want to programmatically close my plugin after the task is done. Is it possible?

If you mean the panel, kind of…

UXP needs a lot of features that CSInterface used to have that were AMAZINGLY useful, including the CSInterface.resize function I used so much in my panels


Or watching selected document change.

what do you exactly mean?

When different document window is activated.

That would be a trigger indeed, but how I could implement closing the panel? I searched here in the forums and the one I found seems to be not implemented yet in UXP.

There is a solution in the topic that I linked. Specifically this post:

This toggles the panel, so you just need to check the state and close if it’s open