It is not necessary to assume the neutron becomes stable within an atom. It goes ahead and decays as usual, but before the muon can decay into an electron and a neutrino, it is attracted to the nearest proton and forms a new neutron. As the protons are arranged on the surface of the nucleus, they are capable of sweeping up all muon. The neutral gap that is thereby created become an attractor for the proton which almost instantaneously mends the gap.
With larger nuclei, occasionally two or more decays can create a larger gap, which persis just long enough for a moun to escape from the atom and be detected as beta decay.