The last rites, in Catholicism, are the last prayers and ministrations given to an individual of the faith, when possible, shortly before death. They may be administered to those awaiting execution, mortally injured, or terminally ill. Last rites cannot be performed on people who have already died.
What in the judgment of the Roman Catholic Church are properly described as the Last Rites are Viaticum (Holy Communion administered to someone who is dying), and the ritual prayers of Commendation of the Dying, and Prayers for the Dead.
The sacrament of Anointing of the Sick is usually postponed until someone is near death. Anointing of the Sick has been thought to be exclusively for the dying, though it can be received at any time. Extreme Unction (Final Anointing) is the name given to Anointing of the Sick when received during last rites. If administered to someone who is not just ill but near death, Anointing of the Sick is generally accompanied by celebration of the sacraments of Penance and Viaticum. The order of the three is important and should be given in the order of Penance (confessing one’s sins), then Anointing of the Sick, and finally the Viaticum. 
Although these three (Penance, Anointing of the sick, and Viaticum) are not, in the proper sense, the Last Rites, they are sometimes mistakenly spoken of as such.
The Eucharist given as Viaticum is the only sacrament essentially associated with dying: "The celebration of the Eucharist as Viaticum is the sacrament proper to the dying Christian".
In the Roman Ritual's Pastoral Care of the Sick: Rites of Anointing and Viaticum, Viaticum is the only sacrament dealt with in Part II: Pastoral Care of the Dying. Within that part, the chapter on Viaticum is followed by two more chapters, one on Commendation of the Dying, with short texts, mainly from the Bible, a special form of the litany of the saints, and other prayers, and the other on Prayers for the Dead. A final chapter provides Rites for Exceptional Circumstances, namely, the Continuous Rite of Penance, Anointing, and Viaticum, Rite for Emergencies, and Christian Initiation for the Dying. The last of these concerns the administration of the sacraments of Baptism and Confirmation to those who have not received them.
In the Orthodox Church and those Eastern Catholic Churches which follow the Byzantine Rite, the last rites consist of the Sacred Mysteries (sacraments) of Confession and the reception of Holy Communion.
Following these sacraments, when a person dies, there are a series of prayers known as The Office at the Parting of the Soul From the Body. This consists of a blessing by the priest, the usual beginning, and after the Lord's Prayer, Psalm 50. Then a Canon to the Theotokos is chanted, entitled, "On behalf of a man whose soul is departing, and who cannot speak". This is an elongated poem speaking in the person of the one who is dying, asking for forgiveness of sin, the mercy of God, and the intercession of the saints. The rite is concluded by three prayers said by the priest, the last one being said "at the departure of the soul."
There is an alternative rite known as The Office at the Parting of the Soul from the Body When a Man has Suffered for a Long Time. The outline of this rite is the same as above, except that Psalm 70 and Psalm 143 precede Psalm 50, and the words of the canon and the prayers are different.
The rubric in the Book of Needs (priest's service book) states, "With respect to the Services said at the parting of the soul, we note that if time does not permit to read the whole Canon, then customarily just one of the prayers, found at the end of the Canon, is read by the Priest at the moment of the parting of the soul from the body."
In the Orthodox Church Holy Unction is not considered to be solely a part of a person's preparation for death, but is administered to any Orthodox Christian who is ill, physically or spiritually, to ask for God's mercy and forgiveness of sin. There is an abbreviated form of Holy Unction to be performed for a person in imminent danger of death, which does not replace the full rite in other cases.
|Wikimedia Commons has media related to Anointing of the Sick (Catholic Church).|