Avoiding trouble whenever possible is your best policy, and generally works pretty well. Yep, we carry guns, knives and know how to handle ourselves, but those measures are a last resort.
Here are five quick tips that will help keep you avoid becoming a victim or having to blow away a dirt bag. Most are pretty obvious, and if you've taken a CCW or self defense course, pretty familiar sounding!
1. Don't go to the gas station at 2:30 IN THE MORNING.
One common thread that I see amongst internet-posted "after action reports" and even on the local news is that, these troubles are occurring at the gas station/truck stop/wherever way late at night. I'm sure this is shocking to you all, but a lot of strange people hit up the gas-n-gulp late at night/early in the morning, and it's probably going to be empty save you and the weirdos. Drunk/high weirdos, late at night...not exactly the kinds of people you want to be alone at the pumps with. Lots of crime happens at gas stations late at night--from robbing the gas station itself to robberies and so on.
Avoid late night Big Gulp/Red Box/smokes/beer runs and you avoid the associated problems! Shocking, I know, but apparently a revelation to many. If you have to stop--say on a road trip--then make sure it's a well lit, fairly busy gas station--bigger truck stops are usually busy 24/7.
2. Live/operate somewhere nice.
A nice, quiet, boring community is a good place to live. If you live in a bad part of town, move. If you don't think you can afford to live somewhere decent, you may need to make a career change/get a better education or relocate to an entirely different area. Check violent crime rates and sex offenders before moving into an area. Slightly higher rent/mortgage or an extra few minutes of commute are worth it if it can get you somewhere nicer/safer.
While random violence can happen anywhere, it's statistically a lot less likely in some areas than others. Avoid areas where there's a higher risk!
3. Pay attention to your surroundings.
The average person walks around almost completely oblivious to what's happening around them. Watch people, especially potentially threatening people. Focus on hands and mannerisms--eye contact can be useful, but it can also instigate a confrontation. Nervous/drug induced fidgeting? Hands in pockets? Hands reaching for something?
Bad guys operate primarily on surprise--don't let them get the drop on you.
4. Trust your gut.
If you get weird/nervous vibes about someone or some place, trust that feeling. Your alarm bells are going off for a reason. Get out. Get in the car and drive away. Consider calling the cops to report a suspicious person.
5. Manage unknown contacts with authoritative commands and smart tactics.
If the first 4 tips have failed you and you've got a stranger approaching you--homeless person, rough looking individual, crazy-acting person--don't let them get up-close-and-personal. That's the whole point--they'll stumble on over under some kind of pretense for needing to know the time, directions, etc. If they really did need to know the time, why would they need to walk towards you?
Challenge them with an outstretched hand and authoritative "Stop." or similar command--"Hold it right there.", "Keep your distance, bud." or an even a "I can't help you."
If you need inspiration, watch a re-run or two of Cops, see how the officers talk to suspected criminals, and then practice. Verbal skills are hugely undervalued and can be very effective.
Repeat yourself, getting louder and firmer. Advice from a former police officer friend of mine: if they've ignored you the first time, you may need to add in an expletive--some people do not respond until they've heard an F-Bomb. Seriously.
While you're using verbal commands, you want to try to generate some extra space or, perhaps even better, get an object in-between you and the contact--your vehicle, an open car door, a shopping cart. If it's some random person knocking on your door, don't open the door. Basically, you want to slow any potential attack.
Finally, you'll need to scan for other bad guys--they tend to travel in packs, and an accomplice closing in on you from another angle is a pretty sure sign that they have violence on the agenda. If there are multiples, try to maneuver so that you can see both of them, lining them up as best as possible.
Be prepared to do violence.
Avoidance may fail. Verbal deescalation may be impossible. You may be forced into a violent encounter, you need to be prepared to win that fight. Quickly and decisively. That takes skill, the proper mindset and proper equipment. If you don't have 'em, go get 'em!