Instead of getting angry, you can simply leave politely, and keep your dignity. That is, if you are absolutely sure they won't hire you. You'd have to have very clear unmistakable evidence for that.

Without such external evidence, you don't know if they really won't hire you. There may be all kinds of reasons for the interviewers' behavior. You don't know what is going on in the interviewers minds, how you compare to other candidates, and what conclusions they will draw.  Taking that into account, you can rarely make a correct preemptive judgement, and without forming such a judgement, there is no reason to become angry.

Both anger and leaving early will **guarantee** that you do not get the job, so they are the poorest choices strategically if you actually want the job.

<sub>Edit, from comment:</sub>
> *OP:* A interviewer might say oh you have no experience with Y and we want someone with X, then [...] I put all this effort trying to learn interview question and the unfairness of the situation, make me get confrontational with the interviewer

There is nothing "unfair" in what you are describing. The purpose of the interview is to find out if your actual expertise and personality is a match for the job, not how well you learned interview questions. Plus, you may get the job despite shortcomings, so jumping to conclusions mid-interview is premature. Since there is no inappropriate behavior on the side of the interviewer, and you experience this as "unfair" with anger, it raises the question if there is an deeper, underlying personal issue, that needs to be addressed in other ways.