'Close and destroy the object.
This is similar to Flush, but does not maintain object validity. Hence the
object should not be interacted with after Close().
Args:
sync: Write the attributes synchronously to the data store.
Raises:
LockError: The lease for this object has expired.'

def Close(self, sync=True):

    if (self.locked and (self.CheckLease() == 0)):
        raise LockError('Can    not    update    lease    that    has    already    expired.')
    if self.locked:
        sync = True
    self._WriteAttributes(sync=sync)
    if self.locked:
        self.transaction.Release()
    if self.parent:
        self.parent.Close(sync=sync)
    self.mode = ''
