Disclaimer: This might be less in line with other answers, as I come from a way more hack'n'slayish game style and role play is only done sparse - much like right from the KoDT pages :)
First and most usual way: the solar cannon - or in your case guards, well trained shopkeepers and accordingly equipped shops. There's a reason that pawn shops and gas stations in some areas and other focal points do feature heavy security.
Then there's a more urgent question you may want to ask yourself:
- Is this really a playable setting?
- Is it a world my players want to play/live in?
- Are they interacting with the proper part of your world?
Worldbuilding is often handled as making up a fairy tale story with a way more trusty and positive assumed structure than in real life (happily ever after already built in). While such a fantasy may be enjoyable when describing it, it's easy to forget all the mechanics that are needed to keep a world like that running.
That's why I like when players come in.
Essentially they are code testers, looking for bugs - or in this case plot holes. A shop without any security will draw thieves - at least as soon as real (and independent thinking) humans are involved. Part of role playing, from a players perspective, is to try other behaviours out than they do in every day life. It is their urge to try your setting. They are not actors following a script.
The same way you got an image about the world you create, the players have an image about the world they want to live in. A real game world will always be a combination of both: it is shaped by the background you set plus the actions the player take. Many of their actions were not imagined by you in the first place. To me that's part of the fun DMing - after all, if one just wants people to enjoy his view, he should rather write a book (or game material), but not run a game.
One lesson here could be selecting only players that adhere to your world view and play along. The other is adapting the world to your players needs (and actions). It needs reaction appropriate to the setting. If they rob a squash stand at a farm house, the farmer will be helpless. If they try the same even at a small village, the villagers will react less than friendly - if they got proper information. In the End, even just a few villagers are a good force.
Unless the PCs go all out war, they will end up send away at least, but usually well beaten up, maybe even including tar and feathers. In a large village, even going berserk won't help much. It's often forgotten, that simple weapon stats are mostly meaningless when confronted with a mob or a well coordinated guard force in a confined space.
Then there's the question about if the part of your world, the PC are in, is the appropriate one. Letting a bunch of high-maintenance low-manners mercenaries into a well off low-security upper class neighborhood may be good for some laughs, but almost never works out as intended. They miss knowledge of the inherent rules (and the smell) of that environment. In some ways it's the same question as about having hired the 'right' players. Adapt the setting or change the players.
In some way your comment about sending them to the woods already shows how to move them into a more appropriate location :))
As always, it comes down to communication which depends a lot on your playing style.
One doing a strict DM vs. Player and everything has to be done in character will of course have a harder time to communicate flawed in-character handling by the player. This is much like in real life, when action and words are not the way they are intended - it's hard for the one acting to spot the flaw. Much like someone believing to be a generous and lovable paladin, while voiceing him more like an arrogant jerk. While this may as well be like in RL, it's more often than not unintended and based on the players poor play of a character's traits. Long story short, a roleplay-targeted style makes it next to impossible to communicate on a meta level about how characters are played. This leaves two alternatives:
- Go along and accept a killing spree by not opening a meta level
- Do it like a director handling his actors between takes. Pause the game and tell exactly what's wrong and needs to be changed.
In the end, it comes down to what has been said about who rules the play. The players due to their actions, or the world builder by definition. With many interrupts and corrections the world builder's fantasy will come thru and players are just actors - sans the money and fame motivating them to comply.
In a more relaxed play style, where metalevel between players and play of characters are intervened, a DM may as well point out flawed handling and give players a direct choice to think again. In my experience, that will lead in the long run to a better handling and understanding of the players about their characters, even including changes in their characters traits without being forced by the DM. Even more, since the meta part is handled with all (or at least the involved) present, players will start to look closer on all characters, help each other and improve the way the characters are played.
This doesn't stop characters from going on a killing spree - just now they will be way more serious about the implications - and accepting reasonable in context reactions by the DM. If they are playing low life, their city environment will be much like above mentioned pawn shops, pre payed pubs and fenced off shop keepers. Not to mention the many nice ways alignmental magic and change of alignment offers.
Bottom line, PCs are not ruining a setting, but improve its design and features.