The Season 6 finale of Game of Thrones was filled with big twists and turns, but nothing compared to Cersei's complete annihilation of King's Landing. Using the wildfire the Mad King had hidden under the city, Cersei burned it all to the ground, something she's been threatening to do since Season 1. Not only did she take out the High Sparrow and the Faith Miltant, she also decimated House Tyrell, killing Loras, Margarey, and their father, Mace. She also got rid of the small council giving herself absolute power over King's Landing. The only person she thought to save was her son, Tommen, but did Tommen have any idea that Cersei was planning to burn everything to the ground before he killed himself?
Prior to being forced to stay in the Red Keep by the Mountain, Tommen probably had no idea what Cersei had planned. Had Tommen known what his mother was planning he would've tried to put a stop to it. It was clear Tommen chose to side with his wife and the High Sparrow once he ended trials by combat basically sentencing his mother to death. If he even had a clue about what his mother was planning, he would've told the High Sparrow immediately and he definitely would've tried to protect Margaery, who he loved so much.
Once the Mountain refused to let Tommen leave the Red Keep to go to his mother's trial, that's probably when Tommen began to suspect something was wrong. Although he didn't know what his mother was up to, he had to have known it wasn't good. Then, as he stood by the window, he watched as King's Landing exploded in green fire, and his love, Margaery, died in the flames. It was only then that Tommen fully understood what his mother had done.
Tommen, who has been used as a chess piece throughout his reign as king, finally realized just how far his mother would go in the game of thrones. Unlike Cersei's past killings, Cersei did this publicly, and not only killed her enemies, but also innocent people who just happened to get caught in the crosshairs. For Cersei, it didn't matter who got hurt in the process, all that mattered was that she won, and seeing King's Landing burn to the ground Tommen finally realized this.
With his wife dead and the realization that his mother would do anything for power, something Tommen has never understood, he decided to take his own life, fulfilling the prophecy Cersei was given as child. Seeing Tommen die this way was heartbreaking because although he made some mistakes he was the most innocent person on the show. He was too good for the world of Game of Thrones, which is why he chose to leave it.