Thank you for the tip!
I changed out the code, but didnt notice any difference when running the program

Right click still closes the incorrect tab when trying to close the selected tab.