How to unload a plugin programmatically?

I wonder if there is a clean way to unload a plugin programmatically. For example when you detect a corrupt installation, an invalid license key, or want to perform an update or things like that. In such cases I would like to show an AlertWindow and then close the plugin but I have no clue how to do that.
Any ideas?

You can’t do it - the host decides when to unload your plugin. What you could do, of course, it just show a blank UI and not make any noise…