Flush unclosed files actively to work around bug #227.

The `RecordStore` and file system related java APIs use `finalize` to flush file data if a file isn't closed explicitly. Since we don't implement `finalize` (#227), we will lose file data in this case.

This pull request flushes the unclosed file periodically and ensures all files are saved before closed.