ui/ncurses: Safely handle lost terminal control commands