Correctly check for a terminated state
Merge pull request #12221 from techhat/issue11934

Correctly check for a terminated state