Added finalize method to run atExit trigger, on both engine termination and error states