Korolev's death in January of 1966 basically threw the entire Soviet space program into the ditch. The Soviets were already behind-- Soyuz wouldn't fly until months later, on Vladimir Kamarov's ill-fated Soyuz 1, and then would have a stand down for a couple years after that. The Soviets hadn't even made the decision to build N-1 and approved a lunar program until mid-64, by which point they were hopelessly behind the United States. The Soviets were also unwilling to expend the same level of effort on their N-1/L-3 program as the US did on Apollo/Saturn. After all, they were STILL playing catch-up with the US in terms of numbers and capabilities of their ICBM's (which they would continue to do so until they passed us in the early 70's and continued to build a huge arsenal of many different types of ICBM's) and their main focus was always on the "military first". Basically N-1 was just getting going good beyond the "paper rocket" stage when Korolev died on the operating table. Mishin was ill-equipped to step into his shoes, and anyway, at the same time, Korolev's old design bureau was handling at least a dozen major projects, from developing new ICBM's, solving the problems with Soyuz and getting it flying safely, participating in interplanetary missions to Mars, Venus, and the Moon, and many other things.
The Soviet's lack of sufficient testing was also the major clincher in their falling behind... they were unwilling to spend the money to build a test stand large enough to conduct a full=fledged test firing of the N-1's first stage. The falling out between Korolev and Glushko over kerosene vs. hypergolic engines, which led Korolev to the aircraft engine designer Kuznetsov, who had never developed a rocket engine before, and was now being tapped to design basically the 1960's kerosene powered equivalent of the SSME, was also problematical. The fact that the NK-33 engines he designed could only be fired ONCE (meaning they were junk after firing, and could not be test fired before their installation on the rocket) meant they were built in groups of six, of which one was test fired to "qualify" the entire batch, which was a poor way of doing it and caused huge problems. N-1's audacious new control system, the KORD, which instead of utilizing gimballing control engines as had been done on previous rockets, instead used "differential throttling" to control the vehicle in flight, was also "a step too far" at least at first, and caused the loss of the first test flight. Kuznetsov's engines and lack of testing was also to blame. One of their N-1's splashed back down right onto the pad and blew up, essentially destroying the pad and requiring a 2 year rebuild. Another N-1 started rotating around it's central axis (spinning) in flight to the point the engines were starved of propellant-- inhibits prevented the vehicle from shutting down prematurely and falling back onto the pad, so the rocket landed a couple miles away and exploded. Corrections took time. The last N-1 test saw the rocket make it to within seconds of staging, when one of the turbopumps on engine 4 exploded, causing the vehicle to go out of control and break up. By this point it was late 1971-- the US had landed on the Moon over 2 years before, the Moon Race was over. The Soviets had flown their first space station, Salyut 1, and had flown 2 flights up to it-- the first docked but were unable to enter because of a damaged docking mechanism on the Soyuz and were forced to return to Earth, and the second was the ill fated Soyuz 11 crew, who after their successful mission to Salyut 1, perished on reentry due to a faulty pressure equalization valve bleeding all their air into space immediately after retrofire and separation of the orbital and instrument aggregate compartments from the crew compartment (the separation of the "service module" in US terms).
The Soviets had decided to use the same "test it in flight" methods they had used successfully in testing their previous missiles and rockets, but this overlooked the ENORMOUS expense of each and every N-1 flight. It had been expensive on the previous missile and space developments-- notably on the R-7 (that launched Sputnik, and was modified for Vostok and Voskhod and again modified for Soyuz). But it was also originally a military missile, thus the expense could be "justified", unlike N-1 which basically had NO military applications, or very sketchy ones at best.
Then there was the fact that basically, the Soviet program suffered from "too much competition". Whereas the US had organized its space program around a centralized 'design and operations" organization (NASA) to which the contractors submitted proposals and NASA selected from, and then oversaw their design and construction of, and actively participated in the design and construction process as well, and then tested and operated those systems on behalf of the US government, in a VERY CENTRALIZED "command" type of program, the Soviets actually had a much more isolated and COMPETITIVE system... while Korolev's OKB-1 and Glushko's organization were the unchallenged front'-runners early in the era of spaceflight, by the early 60's other design bureaus like Yangel and Chelomei were drawing away resources and political favoritism for their own competing projects... there was no "central space agency" within the Soviet Union to oversee space projects-- indeed the space program in inextricably linked to the Soviet military, and overseen directly (via committees) by the Politburo and political leadership. By the time the Soviets decided to make developing a lunar program a priority in 64, their resources were divided and Chelomei was "the fair haired child" and getting more political traction than Korolev, though this changed once the dust settled after Khrushchev's ouster and replacement by Brezhnev... but by that time, Korolev had only months to live. Once Korolev was gone, the drive and brilliance that allowed the Soviets to go so far so quickly had slipped away, and the division of talent, resources, and duplication of programs and capabilities had already done irreparable damage to the Soviet effort.
It's a shame, because the next N-1 flight would in all likelihood have been successful. Kuznetsov had developed "reusable" engines for the N-1, meaning they could be individually test fired before installing on the rocket, and everything else had performed up to par, even the new flight computers and improved KORD control systems. BUT, the Soviets decided to pull the plug and sweep the whole thing under the rug...
Later! OL J R

My MUNIFICENCE is BOUNDLESS, Mr. Bond...