tidy up memory allocated when connection killed