When they do stupid things.
I usually give newbies a "Newbie net" against this sort of thing, but occassionally, I'll have







newbies that I don't pull punches on, and I treat them like any other player. So the badguys, sizing up the party, see that there are squishy mages in the back row, and the party isn't going out of their way to defend said squishy mages, they go after the squishy mages and make them go squish. With polite newbies I'll go after the front liners, but with the jerks (and I've had some real jerks) they get nailed. And then kicked out of the game if they don't simmer down.
I had one player though, who simply couldn't keep his characters alive. He was a really cool guy, and a lot of fun to play with, but just had no sense of self preservation whatsoever in game. His shortest lived character died on the first round of combat which initiated five minutes after having been introduced to the party. Everyone else got away fine, but he just couldn't stop dying. At points, I'd try really hard to help keep him alive, but there are limits. LIMITS man!
I had one entire group die to an EL3 encounter (two gelatenous cubes) when they were level 9. Now THAT was sheer idiocy. The ranged fighters were scouting ahead, and got sucked in first. The melee fighters then went up and fought melee, and got sucked in. Eventually they failed their saves, and none of them made their grapple checks. The last character alive was actually Mr. Can't-Stay-Alive (as above) and finished everything off by fireballing both cubes in close quarters. Very amusing.
Basically, with my encounters, I make sure that there's always a way to survive. Multiple ways to survive, in fact (a game is made up of MEANINGFUL choices, after all)... usually, there's a way to run away, or negotiate, or I simply believe that they are capable of taking the thing down. But despite always having a way through, players sometimes have their characters do stupid things, like charging the entire army of wights instead of teleporting away or negotiating with the Lich King's ambassador... or like calling 13 demons without putting any restraints on them in order to prove they can to some random NPC... or like jumping off into the inky depths believing that despite rolling really high on the will save, I tell them they can't "Disbelieve the illusion".
PCs die when they're basically idiots.