The exact criteria will be given in your ops manual, but basically its the nearest one with appropriate facilities and a suitable weather forecast.
Often the closest may have a very similar weather forecast to the destination, and therefore be unsuitable, so a different one must be chosen. Other (commercial) factors may also be applied, such as fuel prices, transport links and accomodation availability.