What happens when an aircraft type is grounded while in flight? Over the past few days, many countries have decided to ground the 737 MAX. Among these, several have also decided to deny passage to the affected models through that country's airspace. How does this affect flights which were already in the air at the time of the announcement, typically? I can see several options:


The flight returns to its origin, fuel permitting
The flight lands at the closest viable airport in the destination country if fuel is insufficient for a return to origin (minimizing the amount of time in the destination country's airspace)
The flight proceeds to its destination airport as filed, even if this means spending several more hours in the destination country's airspace than the second option
The flight proceeds to the closest viable airport regardless of whether that airport is in some third country being overflown (although I can foresee this causing immigration/visa/customs issues for the passengers)


I'm assuming that (1) is commonly used, given the flight paths on internet flight trackers yesterday, but which of the other options are rooted in reality?
The FAA is currently dealing with that on the 737 MAX.  They are allowing any airborne 737 MAX to continue to its destination or to an alternat or emergency landing site at the discretion of the crew  within the US thence flight ops are prohibited. Special airworthiness certificates and ferry flight permits may be issued by the FAA for moving the aircraft to a home base or maintenance depot as the discretion of the Administrator.