Close the connection and terminate the exiftool process.

        @rtype: C{Deferred}
        @return: A deferred whose callback will be invoked when the connection
        was closed.

def loseConnection(self):
        """
        Close the connection and terminate the exiftool process.

        @rtype: C{Deferred}
        @return: A deferred whose callback will be invoked when the connection
        was closed.
        """
        if self._stopped:
            result = self._stopped
        elif self.connected:
            result = defer.Deferred()
            self._stopped = result
            self.transport.write(b'\n'.join((b'-stay_open', b'False', b'')))
        else:
            # Already disconnected.
            result = defer.succeed(self)

        return result