Allah's Messenger (S) said: "When he commits Hadath - meaning a man - and he is sitting in the end of his Salat before saying the Taslim, then his Salat is acceptable."
Jami` at-Tirmidhi Book 2, Hadith 261