Windows 7 Closing ports

Im writing a port scanner in Java, and what this program does is it scans for any ports which are open and prints the port number out. Now I would like to be able to close a port that is opened?

This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.