Fix close/disconnect issue