md: Close race when setting 'action' to 'idle'.