My daughter is also 5 and sometimes can still act the same way - meaning, she pulled a lot of this stuff at 3 and 4, it has gotten MUCH better, but once in a while she gets in this mode where she just loses it. Usually when she is tired, especially over-tired. Sometimes it's when she's done something wrong, I have to point it out to her or explain why it is wrong, what she should have done instead, etc. and she doesn't want to hear it. Maybe because she knows she screwed up in some way and is sorry, but just wants to move on and not get a lecture from me. Usually if it gets that bad, I will tell her that she needs to go to her room, or go sit in the couch in the other room, by herself until she can calm down. I let her know I understand she's upset, but she can't just scream and yell at me, slam doors, or say hurtful things - there are better ways for her to express herself.
My DD also has a tendency to show her anger by shutting you out - such as, I usually am the one the read her bedtime stories but if she's upset with me for some reason, she will tell me she doesn't want me to read, she wants Daddy. Or if she is upset at Dad, she wants to sit next to me on the couch, not him. I don't let her get away with that though. I don't let her see that it upsets me, I just tell her she don't shut people out when we are angry with them - we talk about it without screaming and yelling. I want her to know it's okay to express all kinds of emotions too but without all the drama. Modeling the behavior you want, and remaining calm yourself helps.
My cousins kids were much the same way at that age - with time and maturity, they got much better, but it did take a while. If they were going on a trip somewhere, they got sad and upset because they were going to miss their cats. Then when it was time to come home, they got sad and upset because they had so much fun and now it was over. It was really draining on her too to have them always crying over something. But they were only little kids with big feelings, and as they got older, it didn't last.
Don't punish her for her negative feelings - but you can discipline for the inappropriate out-of-control behavior and temper tantrums. Just stay firm and consistent, and hang in there - I know it's not easy and I feel your pain!