exiting with correct code