(Fix) Exception catching for closed ports