Decompose exit status check and tidy.