Wait for postgresd to terminate completely in unittest.

Sometimes we would delete postgres's pg_control file before it finished terminating, causing a sigabort to be raised.