fix(harness-codex): close pending step on terminal events (#18615)