after cin >> h failed, it indicated that by setting the std::ios_base::failbit on std::cin. While it is set, I/O functions return immediately, including the input function called from within keep_window_open()
As with any unprocessed input, you need to call cin.clear() to remove the failbit, and then process the input (read it into a string, or ignore with an appropriate cin.ignore)