Chart close event?

 
Hi,
I need to execute some stuff only just before a chart is manually closed. 

What is the right approach to code this? 

Thanks 
 
antony23:
Hi,
I need to execute some stuff only just before a chart is manually closed. 

What is the right approach to code this? 

Thanks 
OnDeinit()
 
void OnDeinit(const int reason)
  {
//---
      if(reason==1)
       {
       }
      if(reason==2)
       {
       }
//---
      //You can detect why your program already de-initialized by reasons and do action in if statement
//---
  }
OnDeinit

This function will call before remove program by any reason

 
Edit:

Yes you are right, reason can be REASON_CHARTCLOSE


Thank you very much!