Mitigating signal loss in force-gradient detection of electron spin resonance