from the Catechism of the Catholic Church:
1523 A preparation for the final journey. If the sacrament of anointing of the sick is given to all who suffer from serious illness and infirmity, even more rightly is it given to those at the point of departing this life; so it is also called sacramentum exeuntium (the sacrament of those departing). The Anointing of the Sick completes our conformity to the death and Resurrection of Christ, just as Baptism began it. It completes the holy anointings that mark the whole Christian life: that of Baptism which sealed the new life in us, and that of Confirmation which strengthened us for the combat of this life. This last anointing fortifies the end of our earthly life like a solid rampart for the final struggles before entering the Father's house.
1532 The special grace of the sacrament of the Anointing of the Sick has as its effects:
- the uniting of the sick person to the passion of Christ, for his own good and that of the whole Church;
- the strengthening, peace, and courage to endure in a Christian manner the sufferings of illness or old age;
- the forgiveness of sins, if the sick person was not able to obtain it through the sacrament of Penance;
- the restoration of health, if it is conducive to the salvation of his soul;
- the preparation for passing over to eternal life.
1514 The Anointing of the Sick "is not a sacrament for those only who are at the point of death. Hence, as soon as anyone of the faithful begins to be in danger of death from sickness or old age, the fitting time for him to receive this sacrament has certainly already arrived."
1524 In addition to the Anointing of the Sick, the Church offers those who are about to leave this life the Eucharist as viaticum. Communion in the body and blood of Christ, received at this moment of "passing over" to the Father, has a particular significance and importance. It is the seed of eternal life and the power of resurrection, according to the words of the Lord: "He who eats my flesh and drinks my blood has eternal life, and I will raise him up at the last day." The sacrament of Christ once dead and now risen, the Eucharist is here the sacrament of passing over from death to life, from this world to the Father.
Also here is an article from New Advent on Extreme Unction.