Psql hangs mid way through script
The problem ended up being some obscure bug in Bash. I was calling psql from a Bash script, which was being called from another Bash script, which was being run from a Cron job, which was redirecting all output to a log file. When I changed it so that Cron directly ran the psql call, and redirected the output, the "hanging" stopped.