What if the titan shifter is in the last moment of his curse, and then the time comes where they die (according to the Curse of Ymir)? Are they still gonna be in their titan form for eternity?
So far, no person with titan-shifter powers experienced this.
But, if I were to speculate what would happen given the facts laid out in the manga, I have a possible answer.
The following facts are what I took into account:
From here, it is said that 'if an individual with the power of the Titans dies before it can be transferred, the power will be passed on to the first Baby among the Subjects of Ymir, who is born directly after the said inheritor's death, regardless of distance or relation to the previous inheritor.'
Also, from here and from what can be observed in the manga, it is known that,
'after death, Titan corpses rapidly evaporate to skeletal remains, then to nothing at all.' From what I understand, this is also true for people with titan-shifter powers whenever they leave their Titan bodies or, for the Colossus Titan's case, when they want their body to evaporate at their own will.
For titan-shifters, they themselves are the source of their Titan powers and their ability to manifest a unique Titan body. If that source is 'gone', then the Titan body would evaporate, as seen in the manga/anime.
So to answer your question: For how long can a titan shifter be in his/her titan form after his/her death while he/she is still inside the Titan's body? The same time it takes for a Titan body to evaporate after it is killed or when a titan-shifter leaves it. After they die, their titan-shifter powers 'leaves' them and are passed on to the next inheritor who is born after the current inheritor's death. Since the 'source' of their power is gone, the Titan body would simply evaporate just like any bodies of Titans killed.