What advice did the Buddha give to laypeople or monastics about taking care of a dying loved one or anyone dying in their deathbed?
First of all, good householder, it's important to take care of yourself, meaning staying within the frames of references.
Second, may good householder gain firm faith into the first Noble truth, and then firm investigate of what else the fear of losing beloved form, sound, smell, taste, touch and giving of thoughts could be.
Once good householder is clear about this first three points it would be good to establish the beloved in Dhamma and faith into the Gems.
If already a follower, or once gained, there are some suttas on how to approach a fellow, either lay or monastic: Advice for sick uninstructed lay people by instructed lay people
In all cases, it any possibility, inviting wise Monks, encourage beloved to make merits and let the Venerable(s) teach the Dhamma for all of you. An hour, a day, 10 days, again and again..
May good householder have the effort to cancel all other useless stuff and spend the whole time in paying gratitude and being generous at one of the right times. Much success toward the Deathless for all of you and your's.
Please read "Ministering to the Sick and the Terminally Ill" by Lily de Silva.
All teachings from the suttas related to this topic are summarized in this essay.
Here's a quote from it.
The Sotapattisamyutta contains a valuable discourse on the question of counseling the terminally ill (S.v,408). Once Mahanama the Sakyan inquired from the Buddha how a wise layman should advise another wise layman who is terminally ill. Here it should be noted that both the counselor and the patient are wise lay Buddhists. The Buddha delivered a whole discourse on how this should be done.
First, a wise layman should comfort a wise layman who is terminally ill with the four assurances: "Be comforted friend, you have unshakable confidence in the Buddha, Dhamma and Sangha, that the Buddha is fully enlightened, the Dhamma is well proclaimed, and the Sangha is well disciplined. You also have cultivated unblemished virtuous conduct which is conducive to concentration."
Having thus comforted the patient with the four assurances, he should ask him whether he has any longing for his parents. If he says yes, it should be pointed out that death will certainly come whether he has longing for his parents or not. Therefore it is better to give up the longing.
Then, if he says he gives up his longing for his parents, he should be asked whether he has longing for his wife and children. With the same reasoning he should be persuaded to give up that longing too.
Then he should be asked if he has any longing for the pleasures of the senses. If he says yes, he should be convinced that divine pleasures are superior to human pleasures, and should be encouraged to aspire for divine pleasures.
Then he should be gradually led up the scale of divine pleasures and when he comes to the highest heaven of the sense sphere, his attention should be diverted to the Brahma-world. If he says he has resolved on the attainment of the Brahma-world, he should be admonished that even the Brahma-world is characterized by impermanence and the rebirth personality.
Therefore it is better to aspire for the cessation of the rebirth personality. If he can establish his mind on the cessation of the rebirth personality, then, the Buddha says, there is no difference between him and the monk who is liberated.