I did exactly the steps you mentioned above. And mine did not crash. I tested several times. No crash.
Anyway, from the documentation, the RemoveBuildTarget requires a string, not a numeric... So I suggest you should try
project.RemoveBuildTarget(Wizard.GetDebugName());
instead.
Maybe you should try to put the project.RemoveBuildTarget here:
// Debug build target
local target = project.GetBuildTarget(Wizard.GetDebugName());
if (!IsNull(target))
//SetupTarget(target, true);
project.RemoveBuildTarget(Wizard.GetDebugName());
}
I am just trying to help out, since my computer not crashing either way.