If you don't need gearing anymore, use AbortCommand to detach the slave axis from the master.
Gear.cpp, add the following code:
VOID RemoveGearSlave(KsCommandStatus gear)
//Remove the gear.
KsCommandStatus abort = AbortCommand(gear);
RtPrintf("The command has not been aborted: %d\n\n", abort.ErrorId);
else if (abort.CommandAborted)
RtPrintf("The command has been aborted.\n\n");