psql with '-c' option or '-f' option is not terminating properly
I need to press the q key as required by less or man for the execution to finish and return to the command prompt?


Sounds like your terminal's pager is taking over the output: you can tell psql not to send its output to the pager when you're using the -c 'select... ' invocation via:

psql --pset pager=off -d database -c 'SELECT * from TABLE'


You may also put the line pset pager OFF in the file ~/.psqlrc, however it seems ~/.psqlrc directives are honored only in interactive mode, not for commands passed in via -c '...'. More great tips for non-interactive psql usage from Peter Eisentraut.