Cleans up and closes connection to remote server if defined.

def close_remote(self):
        """Cleans up and closes connection to remote server if defined.

        """
        if self._remote:
            try:
                # first see if remote dir is still there
                self._remote.execute('ls %s' % (self._remote_id,))
                if self.status != 'Completed':
                    self.remove()
                self._remote.execute('rm -rf %s' % (self._remote_id,))
            except RuntimeError:
                pass
            self._remote.close()
            del self._remote