ENGINE STALLS

While driving, the engine will seem to stall out but not turn off. The gas pedal is unresponsive until speed decreases to approximately 40mph. After we turn the car off, it will run normally for a short period of time and then the condition happens again. What would be causing this?