The Prophet ﷺ prayed, then he stood up after two rak'ahs while he was supposed to sit, and he continued his prayer. Then at the end of his prayer, he performed two prostrations before the Salam, then he said the Salam. (Using translation from Nasāʾī 1177)
أَنَّ النَّبِيَّ ﷺ «صَلَّى فَقَامَ فِي الشَّفْعِ الَّذِي كَانَ يُرِيدُ أَنْ يَجْلِسَ فِيهِ فَمَضَى فِي صَلَاتِهِ حَتَّى إِذَا كَانَ فِي آخِرِ صَلَاتِهِ سَجَدَ سَجْدَتَيْنِ قَبْلَ أَنْ يُسَلِّمَ ثُمَّ سَلَّمَ»