On the stability of the index of unbounded nonlocal operators in Sobolev spaces