In the US, it's pretty straight forward. Squawk 7600. If VMC, land as soon as practicable. If IMC, go back to the route filed or told to expect. If anytime you become VMC, stay VMC and land as soon as practicable.
The *real world* answer is to get you out of the controlled airspace as soon as possible. Don't worry about the route too much, ATC will vector traffic out of your way.
Full details in the AIM Chap. 6.