fix semaphore leak