sounds awfully like the ignition ground is through the brakelight, and that's not working for the above mentioned reasons such as fault in wiring, switch, brakelight or resistor.
Essentially the way those work is the brake lights are powered through the ignition coil's ground. When running and brake levers released, they pass the current directly to a ground (normally open switches means when the button isn't pressed, it's open circuit - kinda confusing because "normally' when youre not pulling the brakes, the button IS pressed, so it's closed circuit til you pull the lever)
so then the way it works is normally brakes released, current is closed and passing to ground and the ignition is grounded and the bike runs. THEN when you pull the brakes, it opens that switch, and the power dumps through a parallel wire to the tail, and grounds through the brake light - and still runs. this lets the brake be brighter and not dim the running lights.
Well! if the taillight's burned out (most common issue of this sort) it can't ground through the brake bulb, and so the igntion is ungrounded, no spark, bke dies.
you can test this by holding the brake and checking for spark. you can also test it by directly grounding the ignition wire that normally goes to the brakes, or by bypassin the brake switch (connect the 2 wires directly) so it never goes open. that'll make the brakelight nonfunctional but it will run even when braking.
The simplest solution is usually replacing the taillight bulbs. but it car rear up if the bulb burns out, and leave you with new troubles so the most RELIABLE solution is to just ground that wire so it always runs. Then if you wanna restore brake light functionality, you've gotta get a normally closed brake switch and run it parallel off the headlight wire. the headlight might dim when braking but this is a simple reliable solution employed by most other mopeds. Or jsut use hand signals cuz a ton of mopeds dont even have brakelights anyway.