Untested fix for deadlock when main() is exiting.