If a person rises for an unintended fifth rakah after omitting the final sitting but has not yet prostrated in that fifth, the proper response is to return to the final sitting, disregard the fifth and perform sujud al-sahw.
The obligatory final sitting is still recoverable, so the underlying fard prayer can remain valid.