Using the code
#targetengine "mine"
var mainmenu = app.menus.items("$ID/Main");
var menu = mainmenu.submenus.add("Test");
I added a submenu to InDesign's menu, that I later removed via
menu.remove();
delete menu;
Unfortunately, when I try to recreate the menu, nothing happens since InDesign seems to think it is still there - until I restart InDesign, after which the menu appears (but without any items added). How can I permanently remove the menu such that it could be recreated later on without having to restart InDesign? The menu also still shows up in InDesign's menu preferences (worse yet, even twice since I tried "Test" and "&Test" as menu names), which I would like to fix as well...
edit Turns out this weird behaviour only occurs when executing the script via InDesign's script panel, but neither via startup nor the ExtendScript toolkit. However, the menu entries still remain after removal.