Python 3.9 is now generally available.

google.appengine.api.runtime.is_shutting_down

Returns true if the server is shutting down.