Fixed ncurses termination bug