Melt 2 tablespoons butter in medium skillet or saute pan over medium-low heat. Add squash and onions and cook until tender.
To a large bowl, add eggs and lightly whisk. Add cheese and milk and whisk into egg until well-combined. Add cooked squash and onions to egg mixture and stir well to combined. Melt remaining 2 tablespoons butter in skillet used to cook squash and onions. Add to squash casserole mixture. Add cayenne pepper, if using, along with salt and pepper. Stir well to combine.
Spray a 9x13 casserole dish with cooking spray and pour squash casserole mixture into the baking dish. Top evenly with crushed Ritz crackers. Place in preheated oven and bake 45 minutes, or until top has lightly browned and casserole does not "jiggle" when the dish is moved.