Did you ever wonder why every damn shop on the whole world/in the entire universe/multiverse buys all the crappy shit you've looted from slain enemies? Usually, I don't think much about it, either, but when I thought about the problem of the player becoming the richest man in the world at the end of most RPGs, I looked for the source of the problem. And usually it's because you can sell everything you loot from slain enemies to shopkeepers, because every single shop does not only sell but also buy. Weaponsmiths gladly pay you 5 gold pieces for a rusty old sword, even though they don't really need it since they got a much better stock to sell and they probably have other sources of buying iron, too. Heck, some shopkeepers even might give you a single gold piece for a bunch of useless rags that have no practical use whatsoever.
Of course, if you sell really useless shit you also get a really low amount of money for it. But since you find a LOT of that stuff over the course of the game, you can earn a small fortune by selling it to various shopkeepers. Usually, if you raise your bartering skill, you can even get quite a good price for your useless shit.
Solution? Make shopkeepers tell you to fuck off when you try selling them stuff they don't need. Or make not every shop in the whole country buy stuff from you. It's completely unrealistic, anyways, that one guy goes into a shop and sells about 50 swords to the shopkeeper and he shells out all the money he has to buy these swords from you. Even though he already has 100 swords on sale and nobody ever buys them. So, just make not everyone buy everything, and make some people buy nothing at all because they're just selling. You can't go into a supermarket and sell them a bar of chocolate, either, even though they do sell chocolate. They already have someone who delivers it to them, so they don't need random people selling them things they looted off anyone's body.
And even if you try selling them something useful, they should pay you less than it's worth. If you have a high haggling skill, most games allow you to sell a chainmail shirt to a shopkeeper for 100 gold pieces, while he sells it for 110. He'd make no profit at all from a deal like that. Nobody would do that in real life. He'd maybe pay you half of what he sells it for. And since 90% of the things you sell to shopkeepers in RPGs are used and also show signs of use (if you kill someone in a fight, both his weapon and armor should show some signs of damage), most of them shouldn't be interested in them in the first place, except if the items are high quality or magical. There could be some second-hand stores, sure, but you wouldn't get that much money from selling things to them. And all you could buy would be cheap worn-out stuff.
So generally, the problem of players ending up with more money than they can spend is not the fact that they can loot so much. It's the fact that shopkeepers buy everything you want to sell them *and* don't offer items of higher quality than you can loot. This should be ideally combined with equipment deteriorating when used, and bang, you got a more realistic system and don't end up being rich.