release acquired semaphores before shutdown