Avoid output disappearing in psql
Assuming your pager is less, try LESS=-FX; export LESS in your shell environment.

From man less:


      -F or --quit-if-one-screen
              Causes less to automatically exit if the entire file can be dis‐
              played on the first screen.

      -X or --no-init
              Disables sending the termcap initialization and deinitialization
              strings to the terminal.  This is  sometimes  desirable  if  the
              deinitialization  string does something unnecessary, like clear‐
              ing the screen.


To have this only in psql, set it with a meta-command in .psqlrc:


\setenv LESS -FX