Fix deadlock on shutdown
Merge pull request #1 from csfrancis/fix_deadlock_on_shutdown

Fix deadlock on shutdown