Venezuela has confirmed it will withdraw from the Organization of American States, accusing it of trying to topple President Nicolas Maduro.