Removing terrain data

I have an on/off button that I want to use to be able to switch the terrain data on and off. It currently works when turning on the data but I am not too sure how to remove it. Is there a way I can achieve this? Below is the code I have:

  function onoff(){
  currentvalue = document.getElementById('onoff').value;
  
  if(currentvalue == "Off"){
    document.getElementById("onoff").value="On";
  
  // Remove goes here...
  
  }else{
    document.getElementById("onoff").value="Off";
  
  viewer.screenSpaceEventHandler.setInputAction(function(movement) {
        var pickedPrimitive = viewer.scene.pick(movement.endPosition);
    }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

    createPrimitives1(viewer.scene, viewer.centralBody.getEllipsoid());
  
  var terrainProvider = new Cesium.CesiumTerrainProvider({
    url : ‘http://cesium.agi.com/smallterrain
});
viewer.centralBody.terrainProvider = terrainProvider;
  }
}

Hi,

You can disable terrain by assigning a default-constructed EllipsoidTerrainProvider.

Kevin

That technique worked thank you very much!