I don't think it really matters. The idea is to set the gain such that a saturated pixel maps to an ADU value of slightly less than 65535. Assuming that your exposure is long and bright enough to saturate the sensor, almost all of the pixels will be saturated with the exception of a very small number of very cold or dead pixels. You know that the max value represents the fully-saturated pixel output, so this is probably a good place to start. The mean should be very close to the same number. If it isn't, it means that the exposure isn't bright enough or that your sensor has a lot of dead pixels that are skewing the mean. So it is probably not a bad idea to look at both. Ideally, you want the gain set such that both the mean and max are close to, but no more than 65535. It is better to err on the low side than the high side. If your mean ends up at, say, 55000, you are still using 15.75 bits of the 16-bit image container and you can be certain that every pixel value gets a unique ADU value. On the other hand, if you err on the high side, you will get some pixels maxxed out at 65535, but you will have no idea how many are maxxed out, or by how much they are maxxed out.
Tim