Stability and control of spacecraft formation flying in trajectories of the restricted three-body problem