def _shutdown_gracefully(self, status=CLOSE_STATUS_NORMAL, reason=DEFAULT_CLOSE_REASON):
        """
        Send a CLOSE handshake to all connected clients before terminating server
        """
        self.keep_alive = False

        # Send CLOSE to clients
        for client in self.clients:
            client["handler"].send_close(CLOSE_STATUS_NORMAL, reason)

        self._terminate_client_handlers()
        self.server_close()
        self.shutdown()

        Send a CLOSE handshake to all connected clients before terminating server
        
src/websocket_server.py