Set exit status according to the result