The IP address remains attached to the VM until you stop it. If you reboot the VM, you will get a new ephemeral IP address.
From the documentation:
Ephemeral external IP addresses are available to VM instances and forwarding rules. Ephemeral external IP addresses remain attached to a VM instance only until the VM is stopped and restarted or the instance is terminated. If an instance is stopped, any ephemeral external IP addresses assigned to the instance are released back into the general Compute Engine pool and become available for use by other projects. When a stopped instance is started again, a new ephemeral external IP address is assigned to the instance.
If you need an IP address to last longer than that, you need to reserve a static external IP address and attach it to that VM. It will remain attached to that VM until explicitly detached, or the VM is deleted.