# How to terminate instance from shell?

**URL:** <https://deeptalk.lambda.ai/t/how-to-terminate-instance-from-shell/3846>\
**Category:** Technical Help\
**Created:** [June 29, 2023, 9:30pm UTC](https://deeptalk.lambda.ai/t/how-to-terminate-instance-from-shell/3846 "2023-06-29T21:30:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![justice](https://sea1.discourse-cdn.com/flex019/user_avatar/deeptalk.lambda.ai/justice/32/617_2.png) [@justice](https://deeptalk.lambda.ai/u/justice)\
**Post date:** [June 29, 2023, 9:30pm UTC](https://deeptalk.lambda.ai/t/how-to-terminate-instance-from-shell/3846/1 "2023-06-29T21:30:13Z")

</div>

I’m trying to terminate my VM at the end of it’s run. `shutdown -P 0` does nothing.

`halt` makes it go go unresponsive. However, the dashboard then shows it with an “alert” status, and it is available to be terminated, so I assume I’m still paying for it until I do so.

Is there a way to terminate the VM from its own shell?

---

<div class="post-metadata">

**Author:** ![yanos](https://avatars.discourse-cdn.com/v4/letter/y/a183cd/32.png) [@yanos](https://deeptalk.lambda.ai/u/yanos)\
**Post date:** [July 4, 2023, 8:49pm UTC](https://deeptalk.lambda.ai/t/how-to-terminate-instance-from-shell/3846/2 "2023-07-04T20:49:28Z")

</div>

From the instance’s terminal, you can only shut down the operating system but you cannot terminate the instance so that it stops being charged.

One workaround is the following and you can run it from any PC or even from inside the instance.

1. Generate a Lambda Cloud API Key  
[GPU Cloud Login | Lambda](https://cloud.lambdalabs.com/api-keys)

2. Run this command to list all your instances:  
[Can I list my running instances from a command line? | Lambda Docs](https://docs.lambdalabs.com/cloud/list-running-instances/)

```auto
curl -u API_KEY: https://cloud.lambdalabs.com/api/v1/instances \
-H "Content-Type: application/json"

```

output:

```auto
{
  "data": [
    {
      "id": "########",
      "ip": "##.##.##.##",
      "region": {
        "name": "us-west-1",
        "description": "California, USA"
      }
    }
  ]
}

```

Find your instance id (“########”) and delete it:

```auto
$ curl -u API_KEY: \
https://cloud.lambdalabs.com/api/v1/instance-operations/terminate \
-d '{"instance_ids":["########"]}'

```

I hope this helps!
