Praise be to Allah.
If this man hastened to leave and he departed from Mina before the sun set, then he found out that there had been a mistake in his stoning of the Jamaraat, so he went back to make it up, then he can do the stoning then leave Mina, because this stoning is to make up for something he had missed out on. Allah, may He be glorified and exalted, says (interpretation of the meaning): “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), and know that you will surely be gathered unto Him” [al-Baqarah 2:203].
But if he delayed stoning on the twelfth until night, then he must remain and spend that night in Mina, then stone the Jamaraat again on the thirteenth. End quote.