fix error handling of finalization call