Stability of compact foliations