Reworked API cleanContext psql sub-process execution (refs #4261)

The exit code from the psql sub-process was not correctly reported.

Connection errors from psql will be reported has error exit code, but SQL
errors in the .sql files will not trigger an error exit code.
Merge pull request #1007 from eguaj/3.2-A4261

Reworked API cleanContext psql sub-process execution (closes #4261)