readline: move pause()

Move pause() before _setRawMode() in close()
Includes regression test
Fixes #5927