Cook the elbow macaroni according to package instructions. Drain and set aside.
In a large pot, melt the butter over medium heat. Add the flour and whisk continuously to create a roux.
Season the roux with salt, black pepper, mustard powder, and cayenne pepper if using. Continue whisking for 2-3 minutes until fragrant.
Gradually pour in the milk, whisking constantly to avoid lumps. Cook until the mixture thickens, about 5-7 minutes.
Reduce the heat to low, and add the cheddar, mozzarella, Parmesan, and Gruyere cheeses. Stir until the cheeses melt and the sauce is smooth.
Add the cooked macaroni to the cheese sauce, stirring until well-coated.
Preheat the oven to 350°F (175°C).
Transfer the mac and cheese mixture to a baking dish and spread it evenly.
Bake in the preheated oven for 25-30 minutes or until the top is golden and bubbly.
Remove from the oven and let it cool for a few minutes before serving.