How do I change the value of an editor text field while it is selected from code

I want to change an editor text field from a script, while it is currently focused and edited. Essentially I want to make sure that the text field no longer has focus.

You could generally make the UI lose keyboard control focus:

GUIUtility.keyboardControl = 0;