How to change logic when system shuts down
OK, new answer since the problem now differs from my original understanding.

I assume you can connect your 2nd PCB to Battery, main PCB power and also intercept the 4 wires to the battery. I assume you can provide enough current through the A and B to turn the motor.

When you detect the main board is off, and the motor is not closed, Isolate B, drive A high. Continue until closed, then you can power off the 2nd board until the main board is powered again.

The easiest way to achieve the control is to use a 2 pole, dual-throw relay. Anything else risks feeding voltage back into the main pcb which could damage it or cause odd effects. Power the relay when you detect the power removed condition, and release power to the relay once you detect closed. Wire the 10 values you need for A/B for when the relay is active. (there are other ways you could switch the relay of course, maybe power the relay when the main board is powered, and use the off state of the relay to pass through your control signal)

Any way round, you probably need to invert the 'CLOSED' signal. Maybe a 2nd relay is the easiest way to do that - relays are reliable, and quite logical.