Closing port on read or permissions error