On process exit, return corresponding error.