To bring about death directly is always against the commandment “You shall not kill”. In contrast, to stand by and assist a dying person is humane and even obligatory. What really matters is whether a dying person is killed or allowed to die. Someone who kills a dying person (euthanasia) breaks the Fifth Commandment. Someone who helps another person in the dying process obeys the commandment “Love your neighbour”. In view of the certain impending death of a patient, it is legitimate to withhold extraordinary or expensive medical procedures that are not proportionate to the expected outcome. The patient himself must make the decision to forgo “extraordinary” measures or must have stated this intention in an advance directive. If he is no longer capable of doing so, those who are legally entitled must represent the express or probable wishes of the dying person. Ordinary care of a dying person should never be discontinued; this is commanded by love of neighbour and mercy. Meanwhile it can be legitimate and in keeping with human dignity to use painkillers, even at the risk of shortening the patient’s life. The crucial thing is that the use of such medications must not aim at bringing about death, either as an end in itself or as a means of ending pain.
(Catholic Youth Catechism, question 382)