# How to Stop Logstash in Windows programatically

**URL:** <https://discuss.elastic.co/t/how-to-stop-logstash-in-windows-programatically/77430>\
**Category:** Logstash\
**Created:** [March 5, 2017, 8:20pm UTC](https://discuss.elastic.co/t/how-to-stop-logstash-in-windows-programatically/77430 "2017-03-05T20:20:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anisen](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@anisen](https://discuss.elastic.co/u/anisen)\
**Post date:** [March 5, 2017, 8:20pm UTC](https://discuss.elastic.co/t/how-to-stop-logstash-in-windows-programatically/77430/1 "2017-03-05T20:20:30Z")

</div>

Hi,

I am using Logstash 5.1.1.

Running logstash in windows command prompt using the command "logstash -f logstash.conf" and stopping it with CTRL+C .

But, I want to stop logstash programatically. Any suggestion on how to do this?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 6, 2017, 9:23am UTC](https://discuss.elastic.co/t/how-to-stop-logstash-in-windows-programatically/77430/2 "2017-03-06T09:23:57Z")

</div>

The GenerateConsoleCtrlEvent() Win32 API is equivalent to pressing Ctrl+C. I don't know if there's another way of shutting down Logstash gracefully (unless you're running it as a service).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 3, 2017, 9:24am UTC](https://discuss.elastic.co/t/how-to-stop-logstash-in-windows-programatically/77430/3 "2017-04-03T09:24:10Z")

</div>

Closed on April 3, 2017, 9:24am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
