If a lock is acquired with a long life-time, and the request then dies without clearing it (e.g. if the web server crashes), the lock isn't cleared automatically, and there is no way to do it using the API (lock_release() and lock_release_all() only releases locks acquired in the same request).
I suggest adding a new method, e.g. lock_force_release($name), that force-releases the semaphore. Of course one should not call this without having checked that the original owner of the semaphore has indeed died.