Assuming it all worked okay before the cracked gear-cog replacement, I'd look at the cable tensions from the motor. They go to hooks either edge of the clamshell, which also apparently have micro-switches.
From a testing point of view, you could start the process ie 5th arc leaves the clamshell, then turn off the ignition which allows you to manually raise the back section high enough for the clamshell to be opened. On the clamshell motor (during disassembly) you probably noticed the spindle can be pushed inwards to disengage it from the motor, allowing for manual turning of the spindle, then see if the hooks move enough to release. This is all from memory when mine played up sometime back, from my experience the the whole roof up/down process is a bit taboo in that you mustn't venture from the "process". In reality I have been able to stop-start it halfway go back forward etc but then I don't have the red indicator which most seem to worry about (I assume it was disconnected by a previous owner).