I'm not sure there is an indisputable answer to this question that doesn't rely on reader interpretation. That having been said, the fact that she shouldn't have died from such a simple wound leads us to a pretty conclusive answer: she consciously chose to halt her regeneration and die.
There are points in the story where we see lesser titan shifters lose all of their limbs, endure metal objects being forcibly embedded in their chests, explode, and generally suffer injuries that would be otherwise fatal to any non-shifter, and then fully recover given enough time. It is implied in the story that only severe damage to the nervous system, such as decapitation, could actually kill a shifter, but we never actually see that happen even though we see some pretty severe looking injuries. Given that Ymir is the f
Founding Titan, and thus the most powerful shifter of all time, she should easily have been able to survive being simply stabbed, even through the heart. Fritz dialogue at the time, "I know that no mere spear can kill you", further supports this conclusion.
We've seen other shifters consciously prevent recovering from wounds, such as when Reiner is bitten in the arm by a titan and suffers a fracture and broken skin; when he decides to reveal himself as the Armored Titan and prepares to kidnap Eren, his wounds immediately heal as he displays his arm for Eren to see. As such, the most obvious supported explanation is that if a shifter suffers fatal injuries, and chooses not to recover, they can die like a regular person might. As to why Ymir chose to do so at that moment, that is a more nebulous question that I'm not sure has an objective answer (although there is plenty of support provided by the story for the reader to draw their own conclusions).