# Disconnect signal

**URL:** <https://discourse.slicer.org/t/disconnect-signal/7226>\
**Category:** Support\
**Tags:** qt\
**Created:** [June 18, 2019, 10:40pm UTC](https://discourse.slicer.org/t/disconnect-signal/7226 "2019-06-18T22:40:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbillah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tbillah/32/4139_2.png) [@tbillah](https://discourse.slicer.org/u/tbillah)\
**Post date:** [June 18, 2019, 10:40pm UTC](https://discourse.slicer.org/t/disconnect-signal/7226/1 "2019-06-18T22:40:01Z")

</div>

I am connected to a figure like below:

```auto
    mainwindow = slicer.util.mainWindow()
    figureHandle= slicer.util.findChildren(mainwindow, className="qMRMLPlotView")[0]

```

Now, I would like to disconnect when File → Close Scene is selected. Is there a signal emitted when Close Scene is selected? For example, I am looking for something like below:

> figureHandle.disconnect(‘when scene is closed’)

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [June 19, 2019, 2:41am UTC](https://discourse.slicer.org/t/disconnect-signal/7226/2 "2019-06-19T02:41:41Z")

</div>

The signals associated with the scene are documented here: [http://apidocs.slicer.org/v4.10/classvtkMRMLScene.html#a8ccb4e378bdb987a4e95ac6cc1067c94](http://apidocs.slicer.org/v4.10/classvtkMRMLScene.html#a8ccb4e378bdb987a4e95ac6cc1067c94)

The relevant signal to observe is `vtkMRMLScene::EndCloseEvent`

For example:

```auto
def onSceneEndCloseEvent(caller, eventId):
  print("Scene close")

slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.EndCloseEvent, onSceneEndCloseEvent)

```

To learn more about efficient way for managing VTK object connections, see also:

- [How can I access callData argument in a VTK object observer callback function](https://www.slicer.org/wiki/Documentation/Nightly/Developers/FAQ/Python_Scripting#How_can_I_access_callData_argument_in_a_VTK_object_observer_callback_function)
- [How to manage VTK object connections ?](https://www.slicer.org/wiki/Documentation/Nightly/Developers/FAQ/Python_Scripting#How_to_manage_VTK_object_connections_.3F)
