Stability results for solutions of elliptic equations with a level surface parallel to the boundary