Programatically hide/restore the default tray from the API

Unfortunately it is not really possible. You can show, but can not hide them…See:

How to make a simple Tray or roullOut in the sketchup? - Developers / Ruby API - SketchUp Community