How to "unselesct" / "deselect" a plugin

Hello I’m working on a plugin for a specific game’s development I’ve made a gui etc. but idk how to deactivate the plugin when that gui’s close button gets pressed. I’ve tried using plugin:Deactivate() and plugin:Activate() but they dont remove the plugin’s outline on the top bar. Does anybody know what I could do?
This is what I’m referring to:
image