fix: avoid last output mismatch in case of an exception during command execution