How to stop a PostgreSQL database with pg_ctl? I am trying to stop the currently running database, because apparently EnterpriseDB on Mac OSX does not support Postgis. And the Postgis site tells me to use Postgres.app. But I cannot stop the currently running database with EnterpriseDB. I tried pg_ctl:

$ pg_ctl stop -D /Library/PostgreSQL/9.6/data
pg_ctl: could not open PID file "/Library/PostgreSQL/9.6/data/postmaster.pid": Permission denied
$ sudo pg_ctl stop -D /Library/PostgreSQL/9.6/data
pg_ctl: cannot be run as root
$ cd /Library/PostgreSQL/9.6
$ sudo chown -R $(whoami) .
$  pg_ctl stop -D /Library/PostgreSQL/9.6/data
pg_ctl: could not send stop signal (PID: 105): Operation not permitted


How am I supposed to do this?
I had to change owner of those files to user postgres and then shut it down via that user:

$ sudo chown -R postgres .
$ sudo su
# su postgres
$ pg_ctl stop -D /Library/PostgreSQL/9.6/data
waiting for server to shut down.... done
server stopped