The longer the combat takes, and the more prep work that goes into setting it up (including battlemats, miniatures, custom statblocks, etc) the more players will tend to believe they are expected to engage in combat when presented with an encounter.
I've personally encountered this one before! Trevor once told me that if he saw that I'd set up a battle grid or had the miniatures close-at-hand, then he'd be more determined to fight than normally. Also, multiple players have told me that seeing a pre-drawn battle environment was very distracting, so I got into the habit of either not drawing it beforehand or drawing it and then hiding it inside my coffee table, haha!
Don't roll dice behind the screen. Or rather, don't roll them behind the screen for numbers/results you're immediately going to give to the players. Attack rolls, damage, saving throws, morale checks - do this all on the table. If you want your players to make choices about fighting or fleeing they need to be able to base that on consistent information: the statistics and probabilities of the game and dice.
This is easily the most convincing argument I've ever read for always playing the dice as they fall. To do otherwise truly IS to deny the players the ability to make decisions based on probabilities of their dice rolls. While I generally prefer that the players make decisions that are in-character before making decisions based on the numbers, if we're playing a game that calls for dice rolls, then by removing those dice rolls from the equation, I'm just putting the players off-balance!
When the players understand all the risks and STILL choose not to back down it's much more dramatic, and while it may end in their defeat it won't feel as much like a random TPK but rather an epic battle they chose on their own.
Again, a good point. Players have the right to make these decisions for their characters, and I shouldn't try to stop them, but it's definitely important that the players KNOW when the encounter is ACTUALLY risky and not just described as risky from the perspective of the setting.(e.g. The farmer is terrified of hobgoblins, but the PCs know that they killed 50 last week.)