Add correct error code on exit