Hook function when taxonomy terms change

You can avoid infinite loop by removing the action before calling update post function.

function maybe_disable_comment($post_id) {
    // do you check if the post has specific custom tax term.
    if ( ! has_term( 'bar', 'YOUR_CUSTOM_TAX', $post_id ) ) {
        return false;
    }

    // remove the filter that will create infinite loop.
    remove_action( 'wp_insert_post', 'maybe_disable_comment' );

    // disable comment.
    wp_update_post( array(
       'ID'             => $post_id,
       'comment_status' => "closed"
    ) );

    // add the action again. (so that next post update hook is handled properly)
    add_action( 'wp_insert_post', 'maybe_disable_comment' );
}
add_action('wp_insert_post', 'maybe_disable_comment');