I really liked the ending. It brings her character full circle. That was the point of her death, to show her Abnegation and that she understood the difference between unecessary and necessary self sacrifice. She struggles with the difference at the end of Divergent and throughout Insurgent. When she goes in instead of Caleb in Allegiant, she understands that her choice was to protect her loved ones, not simply to die. She did not plan on dying, she even says that she wanted to live for her family, her loved ones. But, even the best planned mission goes awry at one point or another.
I felt her death was the end of her character arc. It brought her back to being truely Divergent, not acting rashly out of anger, fear, or even love. She was brave for facing uncertain odds. She was selfless for trying to save her family and friends. She was honest for realizing that, by allowing Caleb to die, she was doing the same thing he did to her in Erudite. She was intelligent for trying to distract David to set off the serum. She was peaceful for accepting her death, and realizing that she could forgive herself. She literally fulfills the ideals of all the factions, Abnegation, Amity, Candor, Dauntless, and Erudite.