add missing fflush() on close - fixes a bug in the lock/unlock order (thx, Cyrus)