There are two important facets of both Midway and Japanese air operations that need to be foregrounded for this answer. First, although Japan did lose four aircraft carriers at Midway, they did not lose them all at once. Kido Butai (the IJN carrier force) lost three carriers (Akagi,Kaga, and Soryu) in a series of dive-bombing attacks over the course of a few minutes at 1025. The fourth carrier, Hiryu, was unmolested and launched a counterattack against the USN. This aggressive and somewhat foolish move guaranteed Hiryu's later destruction during a USN counterstrike later that evening at 1700. The second point is that the majority of the Kido Butai's planes aloft at 1025 were the combat air patrol (CAP) A6M2s. These fighter planes were tasked with the defense of the Japanese fleet and had already given a decent account of themselves in decimating the USN torpedo attacks on Kido Butai. The general estimate from Jonathan Parshall and Antony Tully's Shattered Sword was that the IJN CAP at 1010 was thirty-six fighters which would soon be augmented to forty-two.
What the above means for the OP's question was that there was plenty of time for a number of CAP fighters to land on the intact Hiryu. Shattered Sword estimates that Hiryu took on twenty-seven refugees, all of them fighters save for one strike aircraft straggler from the morning's attack on Midway atoll. This ensured that Hiryu had a fairly robust CAP through the evening but a somewhat anemic striking arm.
The fate of other sixteen CAP aircraft that did not land on Hiryu is a bit more murky. No doubt the USN shot down some of the fighters and the aircraft went missing. Both USN fighter escorts and rear gunners did make claims of A6Ms and although such claims cannot be taken at face value due to the confusion of air combat, the USN undoubtedly did shoot down some of the Japanese CAP. Soryu's fighter ace Fujita Iyozo had to bail out because of damage and he drifted in the water in his kapok lifevest for some four hours until a spotter on the destroyer Nowaki sighted him. Some of CAP also ditched next to smaller Japanese ships like destroyers. This was a standard IJN practice and Kido Butai's carriers usually had a destroyer detached as a plane guard on operations. A number of the damaged aircraft from the morning's strike on Midway ditched rather than try to make a landing. Hiryu's post-1700 CAP of around fourteen A6M2s likewise ditched. There are records of nine fighters ditching and being rescued by surface ships, ironically none of the rescued crew were from Hiryu.
Contrary to the popular historical memory that Midway devastated IJN aircrew, the IJN personnel losses from Midway were severe, but not catastrophic. Surviving manifests from Kido Butai show that only Hiryu and Kaga's air groups suffered from massive losses among pilots and aircrew. IJN carrier doctrine was different than the USN in that pilots were seldom manning their planes until they had been spotted on the deck. While Fuchida Mitsuo relayed the tale of Kido Butai aircraft awaiting takeoff prior to the 1025 attack, this was a fabrication. Photographic evidence from the B-17 attacks two hours prior to the dive-bombing attack show nearly-empty flight decks and it would have taken a herculean effort for the Japanese to arm, fuel, and spot a strike package in that amount of time between the B-17 attacks and the 1025 dive-bombings. The 1025 bombings did extract a heavy toll among fitters and other maintenance personnel, which were losses the IJN found difficult to replace, but a good many of Kido Butai's aviators were away from the conflagrations and escaped their carriers' fate. Some like Egusa Takashige were injured from the attacks, but others like Fujita were not.
Again, contrary to popular stereotypes, the IJN initially filtered the Midway survivors into training or instructor positions. The aggressive Fujita lamented this policy as it denuded frontline units of experienced personnel. The real problem was the material losses at the front outstripped Japan's ability to replace them, so many of these survivors had to be filtered back into combat, often as the replacement chiefs for other units. Fujita for example became Hiyo's divisional officer and Egusa went from leading dive bombers to commanding the 521 Kokutai, a shore-based unit of twin-engined Yokusuka P1Y1 strike aircraft, after his recovery. This was the general pattern for other Midway survivors in which they usually were promoted on the basis of experience to reconstituted or new units, but their experience could not make good on the growing qualitative and quantitative inferiority of Japanese airpower vs-à-vis the American enemy that was apparent by the end of 1942. The majority thus did not survive the war even if they managed to survive the Midway debacle.
Follow up: If rescued, would they have been beaten/tortured/imprisoned for not diving the planes into US vessels?