Paul, that is definitely set up wrong and needs to be sorted immediately
(or temporarily disconnected until you get chance to wire it correctly) to protect your controller.
The later Magic Pie brakes have three wires in their cables:
But only two of the three wires are currently used for the brake switch:
The Black wire is Battery -ve
(Ground) The Red wire is +5V
(which is not currently used) The Blue wire is the brake signal which is switched to ground via the switch when the brakes are applied.
The +5V feed is presumably there to allow Hall sensor type switches to be used instead of the mechanical switches that are currently being used.
Your incorrectly wired brake switches are basically shorting out out the +5V feed whenever the brakes are operated and this will be overloading the +5V regulator incorporated into the controller's electronics, which could fail if it doesn't have some form of overload protection.
The only reason the motor it is cutting out when you operate the brakes is because the +5V supply
(which is also used for the throttle, pedelec sensor and the motor Hall sensors) is being shorted directly to ground.
As the mechanical brake switches are not polarity dependant, the two wires
(Black and Blue) can be connected either way around, but the Red
(+5V) wire must be disconnected and safely insulated to ensure it cannot accidentally short out.
With the brake switches wired up correctly, you should find that the regen will work as expected.
Alan