This is very strange. First of all, closing a filehandle should release all locks - and so should program termination.
But what's even stranger is that the lock is a shared lock. Even if a copy of the program is still around locking the file, that shouldn't prevent another copy of the program from acquiring a lock.
Are you sure that what you are experiencing is because of file locks?