chg: release acquired semaphores before shutdown