The detterance from simply being shot is that theres nothing to gain, and doing so increases your risk substantially.
Now, if there was little risk, such as you're in a shithole that the cops have gave up on anyways, or you're a known and hated gang member that no one will particularly miss, then its another story. But this why an eye-for-an-eye is an almost necessary strategy in lawless areas: the threat of your kin means that killing just you doesn't end the story. In lawful lands, the police play that role.
Of course, some will just ignore the risk and shoot you anyways, but thats just how it goes. After they take your money, they could shoot you too. Hell, if they're really stupid they might even shoot you before.
If they're going to ignore the risk associated with the act, regardless of how risky it is, then there's not much you can do about it. Except shoot them first, I guess.
It's probably not a bad idea to have like $40 in your wallet.