Well, "ports" aren't like portholes or doors, that is, a physical phenomena that you can close. They are actually communications routes and are "opened" by services or applications that want to use them.
That gives you two basic options:
1. Close the application or service that wants to use the port, so it does not get opened.