Mayaqwidgetdockablemixin - unable to capturethe close event


Hi all, I am using mayaqwidgetdockablemixin as my dockwidget in my tool.

Currently I am having an issue where it does not seems to be able to catch the close event as my tool is being closed.

When I tried running it in Maya 2017 while using dockCloseEventTriggered as the signal, it is able to ‘capture’ the close event. However as I tested out using Maya 2018, it is not able to.
As a result, the QSettings that I have used is invalid.

Tried using closeEvent which seems to be giving me the same issue, works in Maya 2017 but not so in Maya 2018.

Not sure if this could be it, but in my code, I did check and query for workspaceControls and delete them should the Maya version be 2017 and above.

Appreciate in advance if anyone has any insights to this.

MayaQWidgetDockableMixin closeEvent is not working