MJ Melendez hit a two-run homer, Salvador Perez drove in the go-ahead run with a two-out double in the seventh inning, and the Kansas City Royals held off the rapidly fading Minnesota Twins 5-4 on Tuesday night to open their final homestand of the season.