I would like to know the Hashkafik understanding of at which stage of a person who is deathly sick do we stop davening for them, and who decides this, also what happens to the tefilos if the person passes on … were they a waste of tefilos?
If a person is deathly sick, and by nature there is no way that the person can recover, one should not continue to daven, because one does not daven for miracles. See Taanis 25, and see Berachos 55, which states that prayer for a pregnant woman to bear a boy is a tefillas shav.
If a person dies, the tefilos as by no means wasted. The entire concept of tefillah is an expression of our relationship with Hashem. In this case, Hashem said ‘no,’ but the very expression of the relationship has great value, and it fulfills an important mitzvah of prayer. In addition, kabbalists explain that even when the prayer does not have its desired effect here, it nonetheless can have great effect on the spiritual domain. Sefer Beis Elokim of the Mabit is one of the books that expounds on this topic.