add flushing feature after close() failed