One of the most telling things in Hamlet is how the way Hamlet shows his thoughts evolves over the course of the play.
It starts with his first soliloquy (I,ii), which he quickly shuts down when Horatio and Marcellus enter, breaking off with "But break, my heart, for I must hold my tongue." The only people privy to his thoughts are the people in the audience, and he's trying his best to keep his feelings to himself, no matter how much it "breaks [his] heart" to do so.
Later, in Act II Scene ii, he opens up in an odd way to Rosencrantz and Guildenstern, with "I could be bounded in a nutshell and count myself a king of infinite space, were it not that I have bad dreams," and the little monologue about how wonderful the world is and "yet, to me, what is this quintessence of dust?" This time, two characters get to hear his thoughts, however flowered, and they either misunderstand them or don't recognize their significance, reading into the idea of his "madness". Either way, their responses are inadequate, even insensitive, and from this point on, he keeps his thoughts between himself and the audience (with the exception of the passion's slave speech).
And then. Then. In Act V Scene ii, "In my heart there was a kind of fighting, that would not let me sleep." Possibly the most straightforward thing he's said in the entire play, and he says it to another character. He's talking to Horatio, letting him in (also, note the past tense). He's finally reached a point where he doesn't need to hide everything going on inside his head, where he knows he has people he can trust and people he can love. He has grown out of his tragedy, and is ready to grow higher.
How terrible, then, that he dies in the very same scene.