A mental health trust chief executive has announced his retirement after nearly four decades in the NHS, and three years leading his organisation.