come ooon, that was pure bullshit, i can understand being a bit mad and overdoing it with fear etc so the story unfolds towards the show's end but destroying the best of what she is supposed to rule at that point makes no damn logic and was made purely for viewer's shock factor on which the whole series was always based on (unless she somehow makes sense in the last episode)
one of the reasons why Breaking Bad has higher rankings overall even though its production budget is abysmal compared to GoT
It makes sense in the context of everything that has lead up to this battle. Even early on Dany has a rather vengeful attitude and narcissistic personality but her most horrifying desires are kept in check by her closest and most trusted advisors. Jorah, Ser Barriston Selmy, and Tyrion all gave her council to show leniency, mercy or generally good advice (e.g Jorah's "There are good and evil people on every side of a war", something she doesn't seem particularly convinced by). The first two are gone and the third she no longer trusts.
When she conquered cities in Essos, she was also welcomed, then loved by the former slaves which plays to her narcissistic personality. At the same time, she was indiscriminately brutal on the slave masters, regardless of their previous actions. A fact Ser Barristan pointedly makes and pulls her back from further brutality until his death. With the Dothraki she's worshipped as some sort of warrior goddess after she burns the Khals.
Now look at what's happened since she's come to Westeros. Instead of worshipping her as their rightful leader Cersei wages a propaganda campaign against her so she's feared. Tyrion's advice becomes less reliable resulting in significant losses to her allies to the point she no longer trusts him. She burns both Tarly's for not bending the knee. She then falls for Jon which ultimately results in her losing one of her dragons (one of the biggest symbols of her power). Then this season she finds out that she's no longer the strongest claim for the throne (and the person who is the right heir is well loved in Westeros). She loses another dragon, she loses the last of her most trusted advisors with the final one essentially telling her to burn the city down before her death (and coming from someone who was effectively a pacifist). She comes to accept the fact that she'll never be loved in Westeros in the same way as Jon. There is no one left that she would trust enough to keep her most brutal desires in check.
In the final battle before she loses it, I saw all of the above coming to a head. This then combined with the fact that she realizes she could have done this from the start and the extra symbolism of the Red Keep as the catalyst/place where her family was killed starting everything bad that has ever happened in her life and I don't think it's any surprise that she completely lost it.