correct exit check after each command