Close open namespace container when error recovery fails. Fixes #9167
Check modifier keys in windows console driver too. Fixes #9091.