Implement termination check.