Roman Catechism 27.42

Chapter 27 — Part III: The Decalogue — The Fourth Commandment

Section 42. Now this happens sometimes because it is better for him to depart from this world before he has strayed from the path of virtue and of duty; for he was taken away lest wickedness should alter his understanding, or deceit beguile his soul. Or because destruction and general upheaval are impending, he is called away that he may escape the calamities of the times. The just man, says the Prophet, is taken away from before the face of evil, lest his virtue and salvation be endangered when God avenges the crimes of men. Or else, he is spared the bitter anguish of witnessing the calamities of his friends and relations in such evil days. The premature death of the good, therefore, gives special reason for fear.