def _before_stop(self) -> None:
        """Synchronously run a script prior to stopping postgres."""

        cmd = self.config.get('before_stop')
        if cmd:
            self._do_before_stop(cmd)
Synchronously run a script prior to stopping postgres.
patroni/postgresql/__init__.py