Added Logic to terminate instance.