Added flushing upon close.