How to force close Popup Window?

Hello, I got a seemingly simple problem. How to close a popup window without selecting off of it?
To be exact I got a popup window with a button. When I press the button I want the window to close, with out having to click off of the window. Any ideas would be much appreciated :slight_smile: Relevant code:

using UnityEngine;
using UnityEditor;

public class CustomPopup : PopupWindowContent {

   // Setup Stuff.
    public override Vector2 GetWindowSize()
    {
        return new Vector2(200, 150);
    }

    public override void OnGUI(Rect rect)
    {
        // But I wish to click to close window.
        if (GUILayout.Button("Close"))
        {           
            // Code to close popup window...
        }
    }
}

Use editorWindow.Close()