Fix crash that happened when commands failed