# Stop Logstash with a Filter or Ruby-Code

**URL:** https://discuss.elastic.co/t/stop-logstash-with-a-filter-or-ruby-code/259000
**Category:** Logstash
**Created:** [December 17, 2020, 1:58pm UTC](https://discuss.elastic.co/t/stop-logstash-with-a-filter-or-ruby-code/259000 "2020-12-17T13:58:25Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [January 11, 2021, 10:59pm UTC](https://discuss.elastic.co/t/stop-logstash-with-a-filter-or-ruby-code/259000/4 "2021-01-11T22:59:09Z")

</div>

I just tried it and it is not going to work. The ruby exit function just raises a SystemExit exception. logstash catches that and logs a 'Ruby exception occurred' message.

That said, what you can do is

```
ruby { code => 'Process.kill(15, Process.pid)' }

```

and the really good news is that logstash catches the SIGTERM and goes through normal shutdown processing. Double cash back bonus!

---

_[View the full topic](https://discuss.elastic.co/t/stop-logstash-with-a-filter-or-ruby-code/259000)._
