Release semaphores in @finally blocks to prevent deadlock in the case of exception