Flush unclosed files actively to work around bug #227.
Merge pull request #639 from yxl/flush

Flush unclosed files actively to work around bug #227.