more orderly shutdown; fixed source of deadlock