you need to have a good firewall software first.
https://www.evorim.com/en/free-firewall or https://tinywall.pados.hu/features.php
Then you set configure it to max security so that you will have to approuve any software or executable that want to connect from your pc to the internet.
You will create a whitelist of sofware like firefox, bittorrent... all the rest will be blocked be default until you allow otherwise.