open/close built in serial monitor from WITHIN sketch

You can't. The Serial Monitor is a program running on your PC and the Arduino has no control over PC programs.

...R