Shut off the engine. This will stop the flow of fuel, which can prevent a full-blown fire from occurring, step out of the car use the fire extinguisher from a few feet away.
NOTE: If smoke or fire is coming from the rear of the car, DO NOT attempt to extinguish it. Immediately get as far away from the car as possible and call 911.