We spend a lot of time in cars and they feel like our personal space - we can feel a false sense of security. It's important that we think about what we would do if somebody attacked us in our car.
If somebody wants to steal your car and they point a gun at you through the window, you'd better let them have the car. But if the weapon is less of an immediate threat there are some things you can do.
If the car is moving a little and there's space to go, lock the doors and drive away as quickly as you can. Hit the horn to startle the attacker and buy a couple of extra seconds, as well as getting the attention of anybody nearby - the last thing the attacker wants. (Don't make them jump if they have a gun!) Even wipers, or a spray of screenwash might help distract the attacker for a moment.
If they are close to the door you could ram it open on them, but this is a risky option as they've then got access to you inside the car - if you do this you'd better be very sure you're hitting them hard enough to end the attack or put if off for a few moments.
It's worth having some sort of weapon in case you need it. Think short, like a rolling pin. (Some steering locks are suitable - keep it handy if you have one). Too long and you can't easily swing it around inside the car. You should also think about jabbing with a short stick for very close quarter fighting. Make sure your weapon is where you can reach it, especially if you expect to drive through a nasty neigbourhood. Beware of knives and guns - they can get you in trouble and they can easily be turned on you. As with everything in self defense, you should practice a little in the car, to see what works on an attacker outside or inside the car with you.
Don't just lash out, think about the pressure points that will have the most impact in a self defense or combat situation.
Awareness, as ever, is important. Before you get to that bad place you really have to drive through, lock the doors and close the windows. Keep moving, don't stop unless you have to. As you approach a stop sign or traffic lights, make sure you're aware of who's around, where they are, what they're doing, what they're holding and your possible escape routes.
If you really think somebody is trying to get at you or somebody else inside the car with really bad things on their mind then stop at nothing. Run them down if you have to. If it's kill or be killed, make sure you're doing the killing.