How to remove "Add Object" menu entry from Add (Shift A) Mesh, after running script "Addon Add Object"?
If you run from the main thread,  via the text editor the &quot;addon&quot; is only registered (the if __name__ == &quot;__main__&quot;  bit).  Doing this is for testing purposes, and is not meant to be  a way to run addons.
To remove, go to python console and type in the following:
bpy.ops.script.reload() 

Or via the menu Blender &gt; System &gt; Reload Scripts
the shortcut for which prior to 2.8 is F8
When an addon is enabled, it is imported as a module and the register method is called. When addon is disabled the module's unregister method is called.
Addons are designed to be enabled and registered via the addons in user prefs, or by putting in scripts folder, or by making it a registered script in the text editor.
Related: unregistering a class
Using the py console.
For single file scripts like above can also emulate them being a module (as if they were imported like an addon) from the python console.
For example if the text block has name &quot;add_object.py&quot; then can &quot;import&quot; it as a module via
&gt;&gt;&gt; add_object = D.texts['add_object.py'].as_module()

call its register method
&gt;&gt;&gt; add_object.register()

and its unregister method, which will remove the draw method from the menu.
&gt;&gt;&gt; add_object.unregister()
&gt;&gt;&gt;