Catch errors while detaching, avoid breaking the editor by failed detaching