function main(projectId, zone, instanceName) {
  // [START compute_stop_instance]
  /**
   * TODO(developer): Uncomment and replace these variables before running the sample.
   */
  // const projectId = 'YOUR_PROJECT_ID';
  // const zone = 'europe-central2-b'
  // const instanceName = 'YOUR_INSTANCE_NAME'

  const compute = require('@google-cloud/compute');

  async function stopInstance() {
    const instancesClient = new compute.InstancesClient();

    const [response] = await instancesClient.stop({
      project: projectId,
      zone,
      instance: instanceName,
    });
    let operation = response.latestResponse;
    const operationsClient = new compute.ZoneOperationsClient();

    // Wait for the operation to complete.
    while (operation.status !== 'DONE') {
      [operation] = await operationsClient.wait({
        operation: operation.name,
        project: projectId,
        zone: operation.zone.split('/').pop(),
      });
    }

    console.log('Instance stopped.');
  }

  stopInstance();
  // [END compute_stop_instance]
}
Stops a started Google Compute Engine instance.

@param {string} projectId - project ID or project number of the Cloud project your instance belongs to.
@param {string} zone - name of the zone your instance belongs to.
@param {string} instanceName - name of the instance your want to stop.