As long as person is living their sin can be forgiven, even shirk as Allah (SWT) says in glorious Qur'an
And those who, when they commit an immorality or wrong themselves [by transgression], remember Allah and seek forgiveness for their sins - and who can forgive sins except Allah ? - and [who] do not persist in what they have done while they know. - Qur'an 3:135
But if someone had died committing shirk his shirk will not be forgiven, any other sin Allah (SWT) may forgive, but shirk, no! as Allah (SWT) says in Qur'an
Indeed, Allah does not forgive association with Him, but He forgives what is less than that for whom He wills. And he who associates others with Allah has certainly fabricated a tremendous sin - Qur'an 4:48
If person has sincerely asked for forgiveness, Allah (SWT) is all knowing all merciful.
and Allah (SWT) knows best