If the pilgrim throws the pebbles on the twelfth day after the sun has passed its zenith, then departs to Makkah or elsewhere before the sun sets, he does not have to throw the pebbles on the thirteenth, and it is not prescribed for him to do so.
In this regard, The Standing Committee for Islamic Research and Ifta’ in Saudi Arabia stated:
“If the pilgrim throws the pebbles on the twelfth day after the sun has passed its zenith, then departs to Makkah or elsewhere before the sun sets, he does not have to throw the pebbles on the thirteenth, and it is not prescribed for him to do so.
Commenting on the verse, “And remember Allah during the appointed Days. But whosoever hastens to leave in two days, there is no sin on him and whosoever stays on, there is no sin on him, if his aim is to do good and obey Allah (fear Him)” (Al-Baqarah: 203), the scholars said:
With regard to the meaning of what is mentioned in the verse: “whoever hastens to depart from Mina after spending two nights there following the Day of Sacrifice, and after throwing the pebbles on the eleventh and twelfth,” there is no sin on him and he does not have to offer a (compensatory) sacrifice, because he has done what is required of him. Whoever tarries in Mina and spends the night of the thirteenth in that place and throws the three pebbles on the thirteenth, there is no sin on him either. Rather his staying in Mina on this night and throwing the pebbles on this day is better and brings a greater reward, because the Prophet (peace and blessings of Allah be upon him) did that.”