Hafeez resigns from the captaincy