Fix end of command state bug.