chg: defer shutdown caused by SIGTERM if necessary
chg: release acquired semaphores before shutdown
Merge pull request #413 from steenpass/resources

release acquired semaphores before shutdown