release semaphore if exception occurs