Guarantee that semaphore is always released