Fix bug of flushWrites too late