using System;
using System.Reflection;
static class WindowClose {
[MenuItem ("Window/Close Game &#c")] // alt + shift + c
static void Close() {
Assembly asm = typeof(EditorWindow).Assembly;
Type type = asm.GetType("UnityEditor.GameView"); // здесь указывать имя класса окна
var window = EditorWindow.GetWindow(type);
if (window) window.Close();
}
}