Fix segmentation fault when metadata are accessed after the session is disconnected.