# Workflow using process.exit

**URL:** <https://community.dynatrace.com/t/workflow-using-process-exit/50174>\
**Category:** Automations\
**Tags:** workflows\
**Created:** [February 10, 2025, 9:01am UTC](https://community.dynatrace.com/t/workflow-using-process-exit/50174 "2025-02-10T09:01:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [February 10, 2025, 9:01am UTC](https://community.dynatrace.com/t/workflow-using-process-exit/50174/1 "2025-02-10T09:01:01Z")

</div>

Good morning,My (workflow) script fetches data in a loop, and when a certain condition is met, the script needs to stop completely. I want to use process.exit for this. Is this a problem?As an more clear example see below:let x = 1;while (x \> 0) {&nbsp;&nbsp;&nbsp;&nbsp;console.log(x);&nbsp;&nbsp;&nbsp;&nbsp;x++;&nbsp;&nbsp;&nbsp;&nbsp;if (x \> 10) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(‘Exiting…’);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;process.exit();&nbsp;&nbsp;&nbsp;&nbsp;}}Any problems in this?KR Henk

---

<div class="post-metadata">

**Author:** ![christian\_kreuz](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/christian_kreuz/32/21669_2.png) [@christian\_kreuz](https://community.dynatrace.com/u/christian_kreuz)\
**Post date:** [February 10, 2025, 2:02pm UTC](https://community.dynatrace.com/t/workflow-using-process-exit/50174/2 "2025-02-10T14:02:19Z")

</div>

As far as I know, process.exit() is not supported by our runtime.

I would recommend doing this via Run JavaScript and “return”:

```javascript
export default async function ({ executionId }) {
  let x = 1;

  while (x > 0) {
    console.log(x);
    x++;

    if (x > 10) {
      console.log('Exiting...');
      return;  
    }
  }}

```

 ![christian_kreuz_0-1739196133012.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/3/a31a785d2f4c75ad566f4994c024d9a3e2d99872.png)

---

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [February 10, 2025, 2:28pm UTC](https://community.dynatrace.com/t/workflow-using-process-exit/50174/3 "2025-02-10T14:28:04Z")

</div>

Hi Christian,

Clear, so if you are in a subroutine&nbsp; you can only do a return out of that routine to prevent spaghetti (-;

KR Henk
