A person may appear to perform good deeds throughout much of life but turn to actions leading to a bad end. Conversely, someone whose earlier life was marked by wrongdoing may turn toward righteousness in the final period.
Outward past actions alone therefore do not establish with certainty whether a person will ultimately be fortunate or wretched. The ending matters, within Allah’s decree.