How to exit gracefully from GCP’s serial console.

Type on the keyboard tilde followed by dot.

~.

That would be tilde followed by a dot.