Issue #180 - Prevent crash when using closed port