Fix a bug that occasionally caused OSRF not to shut down cleanly.