Explicitly release file lock

From PHP 5.3.2, file locks are no longer released automatically when the
file is closed. Adjust to this change in behavior by explicitly releasing
the lock before closing the file.