Why does car come to s halt while still driving it on 2004 Kia Optima

Runs and starts fine after driving for awhile it slows down till it comes to a halt. After letting it cool down it will run normal for another while. Had the transmission oil changed still the same what can it be

1 answer 1 comment
Have it scanned for codes, if engine is stalling, possible crankshaft position sensor.
It doesnt stall motor keeps running but comes to a halt and wont roll no more till it completly cools down