How can I force all currently open sockets in linux to close from the command line?
to flush all your rules in the filter table
at this point all local sockets should be unavailable to a remote host if you have a redhat based os you should also use iptables -X to get rid of their custom chain for INPUT
if you want to the rules to remain on startup then you need to either include these in a script that runs in the /etc/rc.local file or use iptables save
This is all assuming that what you said you want to do is what you want to do.
Maybe it's easier to shut down a specific interface, for example: