Correctly check for a terminated state

Ping @UtahDave.

Fixes #11934.