A senior county fire officer who was at the centre of an investigation over sexist WhatsApp messages has resigned.