If the vm is going to die, why bother killing it at all? Just “make it safe” and let gce kill it.
Could you not just send a signal to the running process that it’s going to die and to hang up or save state or whatever is needed? If an Ephemeral vm ends in a bad state does anyone care?