The vast majority were already aboard their carriers.
Nagumo had postponed sending a follow up strike either to Midway or to hit the US carriers he know knew to be at hand, in order to recover his dawn strike on Midway itself.
Thus at midmorning when Enterprise and Yorktown's Dive Bomber squadrons arrived the hangers were full of aircraft being serviced and rearmed. While each carrier had several Zeroes in the air as CAP(Combat Air Patrol) to protect them, with more being readied to relieve those aloft.
Then in about 10 minutes 3 of the 4 carriers were down for the count. Akagi, Kaga, and Soryu all took hits and were closed for business. Hiryu did manage to escape the initial attack and quickly launched a counter attack with her dive bombers and some fighters, her torpedo bombers would then follow.
Refugee aircraft did land on Hiryu and she was able to keep a modicum of a CAP aloft until she too was sunk by US follow up strikes.
In the end then those remaining pilots simply ditched near the remaining ships of the Kido Butai. There were still 2 battleships, 2 heavy cruisers, a light cruiser, and 12 destroyers present which collected both crews of the sunken carriers and downed pilots.
For more I heartily suggest Shattered Sword by Parshall and Tully as the best modern work on Midway with an eye towards the Japanese perspective.