Mohammad Hafeez has quit as captain of Pakistan's Twenty20 team after they failed to qualify for the semi-finals of the World Twenty20 in Bangladesh.