Add more robust error handling/deallocation to SignFinal

Following the style in VerifyFinal