# Activate a node when closing

**URL:** <https://discourse.nodered.org/t/activate-a-node-when-closing/28396>\
**Category:** General\
**Created:** [16 June 2020 10:31 UTC](https://discourse.nodered.org/t/activate-a-node-when-closing/28396 "2020-06-16T10:31:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hattori](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@Hattori](https://discourse.nodered.org/u/Hattori)\
**Post date:** [16 June 2020 10:31 UTC](https://discourse.nodered.org/t/activate-a-node-when-closing/28396/1 "2020-06-16T10:31:11Z")

</div>

Hello,

I am new to Node-red and i am looking for a node that can be launched when the main window is closing so that i can clean up some project contents. I searched for something like this but did not find anything.

---

<div class="post-metadata">

**Author:** ![cinhcet](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cinhcet/32/438_2.png) [@cinhcet](https://discourse.nodered.org/u/cinhcet)\
**Post date:** [16 June 2020 10:32 UTC](https://discourse.nodered.org/t/activate-a-node-when-closing/28396/2 "2020-06-16T10:32:27Z")

</div>

what do you mean with `main window`?

---

<div class="post-metadata">

**Author:** ![Hattori](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@Hattori](https://discourse.nodered.org/u/Hattori)\
**Post date:** [16 June 2020 10:40 UTC](https://discourse.nodered.org/t/activate-a-node-when-closing/28396/3 "2020-06-16T10:40:43Z")

</div>

I mean the window containing all node, along with each flows and options and ... . The window we usually close with the cross in the top rigth-hhand corner. In my project we have a dedicated soft that contains one tab for Node-red flow creation and another tab that shows the result. But when i do some experiment and then close this soft, i would like to be able to automatically do something.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [16 June 2020 11:24 UTC](https://discourse.nodered.org/t/activate-a-node-when-closing/28396/4 "2020-06-16T11:24:13Z")

</div>

There are no events triggered in the runtime when an editor window is opened or closed - so no, what you want doesn't exist.

---

<div class="post-metadata">

**Author:** ![Hattori](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@Hattori](https://discourse.nodered.org/u/Hattori)\
**Post date:** [16 June 2020 14:05 UTC](https://discourse.nodered.org/t/activate-a-node-when-closing/28396/5 "2020-06-16T14:05:06Z")

</div>

what about this: [https://nodered.org/docs/user-guide/writing-functions#tidying-up](https://nodered.org/docs/user-guide/writing-functions#tidying-up) ? i am not sure when it should trigger ?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [16 June 2020 14:39 UTC](https://discourse.nodered.org/t/activate-a-node-when-closing/28396/6 "2020-06-16T14:39:32Z")

</div>

that is triggered when the flow shuts down - on the runtime side - not the editor side.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 August 2020 14:39 UTC](https://discourse.nodered.org/t/activate-a-node-when-closing/28396/7 "2020-08-15T14:39:47Z")

</div>

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