Nonlocal critical problems with mixed boundary conditions and nearly resonant perturbations