How do you avoid getting angry or upset because you perceived in your mind( and the impression is very strong) they do not want to hire you and you are wasting your time by remaining there.
You learn that there's no need to get angry, and that anger isn't helpful in that context anyway.
Instead, you say something like "I can see that this isn't going to work. Thank you for your time." Then you get up, shake hands and walk out.
That way, you haven't wasted any more time than necessary.
(Yes, I've done this myself)