Exactly! One idea that comes to mind is a pressure switch on the pedal.
If the pedal wants to go faster than your feet it will pull away, release the pressure switch, and cut the motor off. Not easy, but doable.
Or you could just let off the throttle when you don't want the motor spinning your pedals
I would place the motor such that it pulls the pedal sprocket from underneath, not pulling the rear sprocket.
Above, below, in front, behind, it don't matter, it has to reach the back wheel.
The easy way is just mount a sprocket on the left side of your wheel and run the electric to that.
If you want to use your pedal side chain so you have gears that's another thing.
If the pedal sprocket is turning your crank arms then the back wheel sprocket is turning unless the pedal cranks are isolated from the dual sprocket pedal/motor sprockets like a socket wrench.
I know this is a hard concept to follow for most because a pedal sprocket is always directly connected to the right crank arm or crank shaft, that's why back wheel hubs have built in freewheels, so you can coast.
The same principle applies to a freewheel bearing the 2 sprockets attach to but allow the pedal cranks to freewheel so like when your back is turning you don't have to pedal along, when the motor is turning the pedal sprockets the crank shaft crank arms freewheel.
This the budget $20 freewheel bearing that will take 2 sprockets and isolate the crank arms and shaft from any driving force from the second sprocket.
That will hold up for lower power electrics and stock 48cc gas but that's about it, the better ones that will take most anything are ~$80.
This is the pedal crank arms, the right screws into the freewheel bearing to attach it to the pedal crank shaft.
Ya falla?
(sorry, watched 'The Sting' recently and I love that term)