The UN envoy to Yemen has resigned after a failed effort to end violent political turmoil in the country.