jk rowling unilaterally writing that not a single member of slytherin house fought in the battle of hogwarts and instead every single one of them hid like cowards is honestly one of the laziest most flaccid writing decisions of our time
She gave an interview in which she said some of them did return.
JKR: Well, they’re not all bad, that would- I know I’ve said this before, (JN: Yeah, I remember.) and I think I said it to Emerson, they are not all bad, and well, far from it. As we know, at the end they may have (laughs) a slightly more highly developed sense of self-preservation then other people, because- (SU: Yeah, right.) (JN: Yeah.) A part of the final battle that made me smile was Slughorn galloping back with Slytherins, (SU: Yes!) (JN laughs) 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?” (JN: Yeah.) It’s the old saying, (SU: Just…) “There is no truth. (JN: I believe it.) There are only points of view.”
But she didn’t actually write it that way - or if she did, it didn’t make it through editing.