Al-Sha'bi, al-Hasan, Ata and al-Hakam said: He should end his prayer with the salam and then join the imam in his prayer.