This solution worked for me. You need to add this function to the dat.GUI file or manually add it in your code:
dat.GUI.prototype.removeFolder = function(name) {
var folder = this.__folders[name];
if (!folder) {
return;
}
folder.close();
this.__ul.removeChild(folder.domElement.parentNode);
delete this.__folders[name];
this.onResize();
}
Check it out here: dat.gui how to hide menu with code