code: public function close()
      {
          if ($this->_socket !== false) {
              $connection = ($this->unixSocket ?: $this->hostname . ':' . $this->port) . ', database=' . $this->database;
              \Yii::trace('Closing DB connection: ' . $connection, __METHOD__);
              try {
                  $this->executeCommand('QUIT');
              } catch (SocketException $e) {
                  // ignore errors when quitting a closed connection
              }
              fclose($this->_socket);
              $this->_socket = false;
          }
      }
docs: Closes the currently active DB connection.
  It does nothing if the connection is already closed.