Yes, everything of sickness, difficulty, worry or distress that befalls a person, even the prick of a thorn, is an expiation for his sins. Then if he bears it patiently and seeks reward for that with Allaah, as well as the expiation of his sins he will be rewarded for the patience with which he bears the calamity that has befallen him. It makes no difference whether that is at the time of death or before. Calamities are expiation of sin for the believer. The proof of that is the verse (interpretation of the meaning):
“And whatever of misfortune befalls you, it is because of what your hands have earned. And He pardons much”
Since that is because of what our hands have earned, this indicates that it is an expiation for the things we have done. The Prophet SAWS (peace and blessings of Allaah be upon him) said that no worry, distress or hurt befalls the Muslim, not even a thorn that pricks him, but Allaah will expiate his sins thereby.