At Swytch bike we sell devices that will cut off power to the motor when you pull on your brake levers. These are called Brake Sensors.
The Inline Brake Sensor is designed for mechanical brakes. This sensor attaches on to your brake cable, and detects the movement of this cable as you pull on the brake lever.
The Hydraulic Brake Sensor is designed for use with hydraulic brakes. However, It is also compatible with mechanical brakes, and is generally easier to fit as it attaches without interfering with your brake cable / hydraulic tubing. The Hydraulic Brake Sensor involves a magnet and a sensor - when you pull on your brake lever, the magnet is moved away from the sensor, which deactivates the motor.