King Matt the First is very explicitly written for seven-year-olds. It's about a seven-years-old prince, whose father dies, so he becomes king. He tries to be a good king, but there's a war, and he's defeated, and ends up being exiled. There's a sequel - in its end, he dies in a factory accident.
I read King Matt the First when I was seven. For a good while, it was my favourite book.
Why was it that this sad book, and no other "happy end" one became my favourite? Because it touched my like no other book had. It made me think, and it made me feel, and it made me think again. This wasn't "entertainment", a piece of candy, sweet while it lasted, forgotten the moment it was over. This was something more, something deeper. I couldn't have put it into words back then, but I appreciated it nonetheless. I wanted more books like that.
No, it did not traumatise me that Matt didn't get a happy ending. On the contrary: a sad story lets a child experience grief in a safe environment - end of the day, the child knows it isn't real. One can poke at it - reread a sad passage, and then leave it when one doesn't want to be sad for too long, and go play with one's friends. In a way, it prepares a child for real grief.
That said, you need to be explicit with what happens to your protagonist. You can't hide it behind "he went away". Reading The Little Prince when I was seven, it was not clear to me that the prince died, or was never there at all (depending on how you choose to look at it). I took things at face value: magic existed in stories (though it didn't in the real world - don't let anybody tell you that children don't know the difference at that age). This story already had a talking fox and a talking snake, it had magical travel between planets, why wouldn't the snake's bite return the prince to his asteroid?
You hide something, the child doesn't understand and then has it explained to them, the child feels you lied to them. Because, if the character died, why wouldn't you say that he died? And having the narrator lie - that is a disappointment, a breach of trust between storyteller and audience.