Update config

added terminated flag with default value 1. If app exits normally this flag will be changed to 0 before exit. Else it remains 1 (as set at app start).