Need to do WebRequest when ondeinit (chart close specific) but is not possible inside ondenit

 

Hi ppl.

I have an EA and have to control how many contracts(lots) the user can trade, só i have an API and when the EA initializes, the webrequest is done placing the quantity on the database, and if the ea or set is removed, the same webservice is requested and remove this contracts, but i have a problem when closing the chart manually, it seems chart closing is asynchronous and dont let me execute the webrequest placed in ondenit funcion, i receive http error but just when closing the chart manually at X button, any ideas to solve this?

Reason: