Although Mac OS has got an included firewall that only blocks incoming connections. There are commercial alternatives for that also block exfiltrating data : Little snitch and Handoff.
LuLu is the free, open-source macOS firewall that aims to block unknown outgoing connections, unless explicitly approved by the user.