I have 2 forms which set tcp connection. I have 2 buttons connect and stop connection. Problem is if I start connection in 1 Form and click cancel in second Form then TCP connection is stopping and throw error. How to fix it?

Code 1 Form:
using NModbus.Device;
using ModBusHelper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using System.Net.Http;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static ModBusHelper.ModBusExporterLinker;
using static ModBusHelper.ModBusProfile;
using NModbus;
using NModbus.Utility;
using System.Net;

namespace Configurator
{
    public partial class ECTStatePageForm : Form
    {
        CommanderForm CommanderForm;

        BackgroundWorker BackgroundWork = new BackgroundWorker();

        DataTable rmsDataTable = new DataTable();
        DataTable diapsDataTable = new DataTable();

        ModBusProfile ModBusProfileHelper = new ModBusProfile();
        ModBusFunctions ModbusFunctionsHelper = new ModBusFunctions();
        ModBusExporterLinker ExporterLinkerHelper = new ModBusExporterLinker();

        private Tuple<TcpClient, IModbusMaster> _connection;
        private bool __connection_set;

        public ECTStatePageForm(CommanderForm CommanderFormInstance)
        {
            InitializeComponent();
            this.CommanderForm = CommanderFormInstance;

            ModBusProfile.esp esp = ExporterLinkerHelper.esp_Default;

            ste1TextBox.Text = esp.ste[0].ToString();
            ste2TextBox.Text = esp.ste[1].ToString();
            ste3TextBox.Text = esp.ste[2].ToString();
            ste4TextBox.Text = esp.ste[3].ToString();

            rmsDataTable.Columns.Add("Канал", typeof(int));
            rmsDataTable.Columns.Add("Действующее значение тока", typeof(float));
            rmsDataTable.Rows.Add(new object[] { 0, esp.rms[0] });
            rmsDataGridView.DataSource = rmsDataTable;

            diapsDataTable.Columns.Add("Канал", typeof(int));
            diapsDataTable.Columns.Add("Значения диапазонов", typeof(sbyte));
            diapsDataTable.Rows.Add(new object[] { 0, esp.diaps[0] });
            diapsDataGridView.DataSource = diapsDataTable;
            
            BackgroundWork.WorkerSupportsCancellation = true;
            BackgroundWork.DoWork += new DoWorkEventHandler(BackgroundWork_DoWork);

            if (ConnectionManager.IsConnectionActive())
            {
                CurrentConnectionState.ForeColor = Color.OrangeRed;
                CurrentConnectionState.Text = "Соединение уже активно в другой вкладке!";
            }
        }

        private void Get_ECT_State_StartButton_Click(object sender, EventArgs e)
        {
            int modBusPort;
            string boardIP;

            if (BackgroundWork.IsBusy != true)
            {
                if (CommanderForm.BoardIPTextBox.Text != "")
                {
                    boardIP = CommanderForm.BoardIPTextBox.Text;
                }
                else
                {
                    MessageBox.Show("Введите IP адрес устройства.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                try
                {
                    // Attempt to retrieve and parse the ModBus port
                    try
                    {
                        modBusPort = int.Parse(CommanderForm.ModBusPortTextBox.Text);
                    }
                    catch (FormatException)
                    {
                        MessageBox.Show("Неправильный формат номера порта. Пожалуйста введите целое число.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    catch (ArgumentNullException)
                    {
                        MessageBox.Show("Введите номер порта ModBus.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    try
                    {
                        CurrentConnectionState.ForeColor = Color.DarkGray;
                        CurrentConnectionState.Text = "Подключение...";
                        _connection = ConnectionManager.OpenConnection(boardIP, modBusPort);
                        __connection_set = true;
                    }
                    catch (ArgumentException ex)
                    {
                        CurrentConnectionState.ForeColor = Color.Red;
                        CurrentConnectionState.Text = "Ошибка подключения!";
                        MessageBox.Show("Ошибка ввода: " + ex.Message);
                        return;
                    }
                    catch (InvalidOperationException ex)
                    {
                        CurrentConnectionState.ForeColor = Color.Red;
                        CurrentConnectionState.Text = "Ошибка подключения!";
                        MessageBox.Show("Ошибка соединения: " + ex.Message);
                        return;
                    }

                    // Start background work
                    try
                    {
                        CurrentConnectionState.Text = "Подключено!";
                        CurrentConnectionState.ForeColor = Color.Green;
                        BackgroundWork.RunWorkerAsync();
                    }
                    catch (InvalidOperationException ex)
                    {
                        MessageBox.Show($"Невозможно запустить процесс в фоновом режиме: {ex.Message}", "Ошибка запуска процесса", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show($"Ошибка: {ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }

        private void Get_ECT_State_CancelButton_Click(object sender, EventArgs e)
        {
            if (BackgroundWork.WorkerSupportsCancellation == true)
            {
                if (ConnectionManager.IsConnectionActive() && __connection_set)
                {
                    ConnectionManager.CloseConnection();
                }
                BackgroundWork.CancelAsync();
            }
        }

        private void BackgroundWork_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            while (e.Cancel == false)
            {
                if ((worker.CancellationPending == true))
                {
                    e.Cancel = true;
                    break;
                }
                else
                {
                    // Perform a time consuming operation and report progress.
                    ModBusProfile.esp espValues = ModBusProfileHelper.ect_state_page_Read(_connection.Item2);
                    ste1TextBox.Invoke(new Action(() =>
                    {
                        ste1TextBox.Text = espValues.ste[0].ToString();
                    }));

                    ste2TextBox.Invoke(new Action(() =>
                    {
                        ste2TextBox.Text = espValues.ste[1].ToString();
                    }));

                    ste3TextBox.Invoke(new Action(() =>
                    {
                        ste3TextBox.Text = espValues.ste[2].ToString();
                    }));

                    ste4TextBox.Invoke(new Action(() =>
                    {
                        ste4TextBox.Text = espValues.ste[3].ToString();
                    }));

                    if (espValues.rms.Length > rmsDataTable.Rows.Count)
                    {
                        for (int i = 1; i < espValues.rms.Length; i++)
                        {
                            rmsDataGridView.Invoke(new MethodInvoker(() =>
                            {
                                rmsDataTable.Rows.Add(new object[] { i, 0 });
                            }));
                        }
                    }
                    else if (espValues.rms.Length < rmsDataTable.Rows.Count)
                    {
                        int current_row = rmsDataTable.Rows.Count - 1;
                        while (espValues.rms.Length < rmsDataTable.Rows.Count)
                        {
                            rmsDataGridView.Invoke(new MethodInvoker(() =>
                            {
                                rmsDataTable.Rows[current_row].Delete();
                            }));
                            current_row--;
                        }
                    }

                    if (espValues.diaps.Length > diapsDataTable.Rows.Count)
                    {
                        for (int i = 1; i < espValues.diaps.Length; i++)
                        {
                            diapsDataGridView.Invoke(new MethodInvoker(() =>
                            {
                                diapsDataTable.Rows.Add(new object[] { i, 0 });
                            }));
                        }
                    }
                    else if (espValues.diaps.Length < diapsDataTable.Rows.Count)
                    {
                        int current_row = diapsDataTable.Rows.Count - 1;
                        while (espValues.diaps.Length < diapsDataTable.Rows.Count)
                        {
                            diapsDataGridView.Invoke(new MethodInvoker(() =>
                            {
                                diapsDataTable.Rows[current_row].Delete();
                            }));
                            current_row--;
                        }
                    }

                    for (int k = 0; k < espValues.rms.Length; k++)
                    {
                        rmsDataTable.Rows[k][1] = espValues.rms[k];
                    }
                    rmsDataGridView.Invoke(new Action(() =>
                    {
                        rmsDataGridView.DataSource = rmsDataTable;
                    }));
                    
                    for (int z = 0; z < espValues.diaps.Length; z++)
                    {
                        diapsDataTable.Rows[z][1] = espValues.diaps[z];
                    }
                    diapsDataGridView.Invoke(new Action(() =>
                    {
                        diapsDataGridView.DataSource = diapsDataTable;
                    }));
                    
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }

        private void ECTStatePageForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (BackgroundWork.WorkerSupportsCancellation == true)
            {
                if (ConnectionManager.IsConnectionActive() && __connection_set)
                {
                    ConnectionManager.CloseConnection();
                }
                BackgroundWork.CancelAsync();
            }
        }
    }
}