Prevent trying to close an unopened port.