While I wholeheartedly agree with your comment regarding constant usage and symbol names with flock, the question of releasing locks has been discussed previously here - The summary of this thread was that it wasn't necessary to unlock a file if you were about to close the file as the lock will be released by the closure.