Change termination detection mechanism

Using static object (exit variable)