'Flush, set the target to None and lose the buffer.'

def close(self):

    try:
        self.flush()
    finally:
        self.acquire()
        try:
            self.target = None
            BufferingHandler.close(self)
        finally:
            self.release()
