'Closes the stream.'

def close(self):

    self.acquire()
    try:
        if self.stream:
            self.flush()
            if hasattr(self.stream, 'close'):
                self.stream.close()
            self.stream = None
        StreamHandler.close(self)
    finally:
        self.release()
