Why do you need to control the brake like this?
Stepper motors have full torque at 0rpm. If the stepper is powered you should not need the brake. Brake should be turned off when the CNC is powered on, then brake should reactivate when CNC is powered down.
Or is this a brake for 4th axis machining?
Brakes integrated into steppers or servos are not designed to be used for machining, they are jus to hold axis position when the motor is off. Usually to stop Z axis falling under gravity.