Set proper return code on exit