Merge: #8862: Fix curses cleanup with getchar is interrupted by a signal.

I have no idea how one would write a test for this.

Patch by July Tikhonov.