It is narrated from Sayyiduna Ibn Umar (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings be upon him) said: Allah Almighty accepts the servant’s repentance even before the state of agony of death overtakes him.
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 6160
Hadith Gradingحکم دارالسلام:إسناده حسن من أجل ثوبان .