Sweet, glad you got it sorted. The thing with the Bafang motor, is that the PAS sensor is part of the final drive cog, not part of the pedal axle. If any overrun causes the chainring to keep rotating, then the motor keeps going.
Must have been annoyingly confusing for you, when the main pedals...