Fix shutdown deadlock, ticket #2690

See commits for explanation. Busted boost release, this works around it.

This affected fedora 18, and probably Ubuntu Quantal as well.