osd: fix race during shutdown