Automatic disconnection when closing added