Exits psql and returns to the shell; Ctrl+D works too. In scripts, psql -c and psql -f exit automatically when done. Related: \! runs a shell command without leaving psql.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.