Check for boolean values first. Fixes #9742.

Instead of raising `RuntimeError`, raise `TerminalException`.