The Messenger of Allah ﷺ stood up (at the end of two rak'ahs) when he had to sit and proceeded on with the prayer. But when he was at the end of the prayer, he performed a prostration before the salutation and then pronounced the salutation.
أَنَّ رَسُولَ اللَّهِ ﷺ قَامَ فِي الشَّفْعِ الَّذِي يُرِيدُ أَنْ يَجْلِسَ فِي صَلاَتِهِ فَمَضَى فِي صَلاَتِهِ فَلَمَّا كَانَ فِي آخِرِ الصَّلاَةِ سَجَدَ قَبْلَ أَنْ يُسَلِّمَ ثُمَّ سَلَّمَ