call unlock only if this process still owns the lock

calling unlock when the process doesn't own the lock anymore can have other side effects - some other process holding a valid lock will lose it.