Can't destroy object created in editor

In a script I run I need to create an object. However once the script has run I would like to destroy the object, but I can’t figure out how to do it.

This sample highlights the problem

using UnityEngine;
using UnityEditor;

public class WillNotDestroy : EditorWindow
{
    [MenuItem("Custom Tasks/Create And Destroy")]
    static void CreateAndDestroy()
    { 
        GameObject go = new GameObject();
        go.name = "Help destroy me";
        Destroy(go);		
	}
}

You have to use DestroyImmediate instead of Destroy.And you can’t invoke a delayed destruction in editor script.

DestroyImmediate(go);    

You can read more about it here