Ncurses loop breaking