I need to close the charmBar program code, how can I do this?
Try focusing on a different control. For example call
this.Focus();