The Dr who treated my brother while he was dying explained this really well; the reduced pain can actually extend life (on the order of minutes) because the reduced discomfort/pain allowed him to continue breathing longer than he would have otherwise.