During the Battle of Hogwarts, the students were given the choice to leave or stay and fight. I remember reading somewhere that most of Hufflepuff stayed and fought, more so than any other house. This would imply some students did not stay and instead left. When/how did they do this?
As dlanod says in his answer, the student were evacuated through the painting in the Room of Requirement that led to the Hog's Head, to Disapparate from Hogsmeade (or presumably to be picked up by parents or relatives; perhaps the Hogwarts Express was called up for duty) This occurred before the Battle of Hogwarts.
‘There’s a way,’ said Harry quickly, and he explained about the passageway leading into the Hog’s Head.
‘Potter, we’re talking about hundreds of students –’
‘I know, Professor, but if Voldemort and the Death Eaters are concentrating on the school boundaries they won’t be interested in anyone who’s Disapparating out of the Hog’s Head.’
‘There’s something in that,’ [McGonagall] agreed.
Deathly Hallows - page 479 - UK - chapter 30, The Sacking of Severus Snape
I personally cannot find any canon reference to the Hufflepuffs staying in greater numbers. Ernie Macmillan and Hannah Abbott are mentioned during the course of the Battle of Hogwarts. Zacharias Smith bolted:
Harry saw Zacharias Smith bowling over first-years to get to the front of the queue...
Deathly Hallows - page 492 - UK - chapter 31, The Battle of Hogwarts
It is mentioned that Ravenclaws and Gryffindors stayed to fight:
Slowly, the four tables emptied. The Slytherin table was completely deserted, but a number of older Ravenclaws remained seated while their fellows filed out: even more Hufflepuffs stayed behind, and half of Gryffindor remained in their seats, necessitating Professor McGonagall’s descent from the teachers’ platform to chivvy the under-age on their way.
Deathly Hallows - page 491 - UK - chapter 31, The Battle of Hogwarts
(You can see that more Hufflepuffs stayed than Ravenclaws and half of Gryffindor stayed; it's not stated either way whether the half of Gryffindor that stayed numbered more than the Hufflepuffs)
Voldemort claimed the Slytherins joined his side after leaving the Great Hall.
‘If your son is dead, Lucius, it is not my fault. He did not come and join me, like the rest of the Slytherins. Perhaps he has decided to befriend Harry Potter?’ (Voldemort)
Deathly Hallows - pages 515-516 - UK - chapter 32, The Elder Wand
Whether or not that was true, they came back to Hogwarts and fought against Voldemort alongside their classmates.
JKR: A part of the final battle that made me smile was Slughorn galloping back with Slytherins, but they’d gone off to get reinforcements first, you know what I’m saying? But yes, they came back, they came back to fight, so I mean- but I’m sure that many people would say “Well, that’s common sense, isn’t it? Isn’t that smart, to get out, get more people and come back with them?”
J.K. Rowling - Pottercast No. 131 - The Leaky Cauldron - 01.02.08
Hopefully this isn't too much information!
They left via the painting inside the Room of Requirement that Harry entered Hogwarts through. It lead to Aberforth's bar in Hogsmeade.
"Potter!" Aberforth Dumbledore stood blocking the corridor ahead, his wand held ready.
"I’ve had hundreds of kids thundering through my pub, Potter!"
"I know, we’re evacuating," Harry said