My issue was that I was searching for widgets before they were initialized. Placing my code in the Construct_Implementation() corrects the issue. Another gotcha I encountered was making sure the “exitGame” function was a UFUNCTION().
void URoMMainMenuWidget::Construct_Implementation()
{
Super::Construct_Implementation();
UButton* exitButton = (UButton*) GetWidgetFromName(TEXT("exitButton"));
exitButton->OnClicked.AddDynamic(this, &URoMMainMenuWidget::exitGame);
}
void URoMMainMenuWidget::exitGame()
{
GetWorld()->GetFirstPlayerController()->ConsoleCommand("quit");
}