cacth port_close to ignore closed port errors, fixed index bug when looking for pty