did you replace the rotary switch on the end of the barrell?
this failed on my old car, and would do the same as you describe, would turn off when driving along..bad
you can take the switch off the back of the barrell very easily (its actually scary how easy it is), then just shove a screwdriver in the switch and try and turn it (same as turning your key)
the switch should have definite positions, if its all loose (no clicks) then off to the wreckers for another one