 Japanese settled in the northern half of Karafuto; after Japan agreed to hand this half back to the Soviet Union, some may have chosen to remain north of the Soviet line of control.However, the majority would remain in Japanese territory until the closing days of World War II, when the whole of Sakhalin came under Soviet control as part of the USSR's invasion of Manchuria; most Japanese fled the advancing Red Army, or returned to Japan after the Soviet takeover, but others, mainly military personnel, were taken to the mainland of Russia and detained in work camps there.Furthermore, roughly 40,000 Korean settlers, despite still holding Japanese nationality, were denied permission by the Soviet Government to transit through Japan to repatriate to their homes in the southern half of the Korean peninsula.