[Ide] Robustify the removing/re-adding of event handlers in the MainToolbar with try/finally