finished exit logic and replace main activity to a new one.