speeding up closest_words by early stopping the edit distance algorithm when reaching a thresholod