here is the simplest ‘fail’, straight from the API plus a name change…
model = Sketchup.active_model
materials = model.materials
material = materials.add('Joe')
material.color = 'red'
material.name = 'Red'
# # these don't clear the 'Joe' material...
materials.current = materials['Red']
materials.purge_unused
# but will purge 'Red' without materials.current line
UI.update_inspectors # 'Colors' is not an inspector panel
# this will expose a closed panel with both materials
Sketchup.send_action('orderFrontColorPanel:')
## this is the only way found from code to clear 'Joe'
Sketchup.send_action('newDocument:') ## New ### ⌘N
Sketchup.send_action('performClose:') ## Close ### ⌘W
Also, on Windows editions, SketchUp does not use the separate system based color panel (as it generally stinks, especially the old version left over from Windows 3.x/4.x days. Devs need to be careful to explicitly use newer versions of the common dialogs library, normally thru a entry in the dependent assemblies section of the executable’s manifest.)