In general, unmanned flight control systems operate in one of two main modes: manual control and program. (There are other modes but these are typically specific situations, such as launch/landing sequences, loss of link (aka "return home"), and any other design-specific operating modes as required (see below).
To answer your question, if link is lost while the aircraft is in manual operation, a good flight system will automatically go into "return home" mode, where it flies to a pre-programmed GPS coordinate and altitude. Some software will allow you to customize the sequence, such as whether or not to spiral up to altitude before heading to that coordinate. Other software will backtrace the route it took.
Aircraft following a pre-programmed route typically change to manual mode upon completion, hoping there's a good ground link at the other end. In military operations, this is known as a "hand-off" where one ground station takes control from another.
One Shadow flight I was running lost link immediately after launch. After completing its autolaunch sequence, it went to return home and circled for hours until it ran out of fuel, at which point the engine stalled and the generator (alternator) hiccuped in transition to battery power, causing the flight processor to reboot, at which point we re-acquired link, though too late to do anything about it. The UAV had already noticed its engine wasn't spinning and initiated its ditch sequence, rolling over and popping the chute.