Fixed an error in the close-port function. Closes bug #719396.