Autofeedback scheme for preservation of macroscopic coherence in microwave cavities