def close(self):
        """Close the process and frees its associated resources.

        This method waits for the resources to be freed by the event loop.
        """
        if self._process is None:
            return
        waitfor = []
        if not self._process.closed:
            self._process.close(self._on_close_complete)
            waitfor.append(self._closed)
        # For each of stdin/stdout/stderr, close the transport. This schedules
        # an on-close callback that will close the protocol, which we wait for.
        if self._stdin:
            self._stdin[1].close()
            waitfor.append(self._stdin[1]._closed)
        if self._stdout:
            self._stdout[1].close()
            waitfor.append(self._stdout[1]._closed)
        if self._stderr:
            self._stderr[1].close()
            waitfor.append(self._stderr[1]._closed)
        futures.wait(waitfor)
        self._process = None
        self._stdin = self._stdout = self._stderr = None
Close the process and frees its associated resources.

        This method waits for the resources to be freed by the event loop.