'Closes the stream.'

def close(self):

    if self.stream:
        self.flush()
        if hasattr(self.stream, 'close'):
            self.stream.close()
        StreamHandler.close(self)
        self.stream = None
    return
