exit with appropriate status code