MQL4 Reference Predefined Variables _UninitReason
The _UninitReason variable contains the code of the program uninitialization reason.
Usually, this code is obtained by UninitializeReason()the function.