'Abdullah bin 'Umar bin Al-Khattab (May Allah be pleased with them) reported that:
The Prophet (ﷺ) said, "Allah accepts a slave's repentance as long as the latter is not on his death bed (that is, before the soul of the dying person reaches the throat)".[At-Tirmidhi, who categorised it as Hadith Hasan].
Arabic/English book reference: Book 1, Hadith 18