PHOENIX (AP) -- The Arizona Diamondbacks desperately needed a win to avoid falling further behind in the race for a National League wild-card berth, and a pitcher who hadn't won at home in 2 1/2 months delivered.
''The simplest way to put it is that I felt more like myself,'' Kelly said after his first win at Chase Field since June 2. ''I went out there with a specific game plan of throwing everything at any time.
''Everybody in here still believes we can still make a run at this thing, we can still do something,'' Kelly added. ''Obviously losing four in a row, I'd be lying if there wasn't an extra incentive on today's game.''
Wilmer Flores and David Peralta homered, and Kelly (9-12) struck out five. Madison Bumgarner (8-8) took the loss after giving up four runs on six hits in six innings of Bruce Bochy's final game at Chase Field as Giants manager.
Bochy, who is retiring at season's end, was honored before the game with a videoboard and public address announcement. He then walked to home plate, where Diamondbacks manager Torey Lovullo presented him with an all-inclusive, four-night stay at a lodge in Montana.
''It was classy for him to come out and what the Diamondbacks did for me,'' Bochy said. ''It was a good series. You come in here and take three out of four, hey, you have to feel good about that.''
The Diamondbacks struck early with three first-inning runs. A two-out fielding error in right field by Austin Slater allowed Eduardo Escobar to take third base on a double, and after a walk, Adam Jones tripled when the ball got past Giants center fielder Kevin Pillar to drive in two runs.
Josh Rojas drove in Jones for a 3-0 lead off Bumgarner, who had nine strikeouts.
Flores hit an 0-2 pitch from Bumgarner in the fifth deep into the left field seats for his sixth home run of the season. Flores is 12 for 19 (.632) with four home runs and seven RBIs in his last six games.
Kelly walked two more hitters to load the bases with two outs, but Andrew Chafin got Brandon Crawford to bounce out to end the inning, covering first base to run down a toss from Flores.
''It's one of the hardest throws for a second baseman,'' Flores said. ''I had to make sure I made a strong throw.''
Peralta's seventh-inning line drive just cleared the right field fence and landed on the pool deck, his 12th of the season.
A FAREWELL TO CHASE
Bochy has spent decades coming to Arizona as a player, coach and manager. He said he thought about his final game in Phoenix walking into the ballpark Sunday morning. He managed the National League at the 2011 All-Star Game in Phoenix and after Sunday finished 69-53 at Chase Field as manager of the Giants.
''The last day is usually when it hits me,'' he said. ''I thought about all the games I've had here, big games, over the years. The first year was '98, so that was a good year. We went to the World Series that year (as manager of the San Diego Padres).
''I've seen some great teams here, great battles. Of course when they had (Randy) Johnson and (Curt) Schilling, they were as tough as anybody,'' Bochy added. ''I'll miss coming here. They've done a great job here putting together a team and how they play.''
The Giants called up infielder Abiatal Avelino, who grounded out as a pinch hitter Sunday, before the game from Triple-A Sacramento. Pitcher Travis Bergen was designated for assignment.
The Diamondbacks brought up right-hander Bo Takahashi from Double-A Jackson, with pitcher Stefan Crichton optioned to Triple-A Reno. Takahashi, 22, is the first Diamondbacks player born in Brazil and the sixth overall to reach the major leagues.
Giants: RHP Shaun Anderson was eligible to come off the 10-day injured list Sunday after a blister healed, but Bochy said he's likely to get a rehab start before being activated.
Diamondbacks: IF-OF Ketel Marte was out of the lineup a second straight game. He dealt with back tightness Saturday.
Giants: After an off day Monday, the Giants send RHP Tyler Beede (3-7, 5.77 ERA) to the mound against the Chicago Cubs and Cole Hamels at Wrigley Field to open a key three-game series against another NL postseason contender.
Diamondbacks: RHP Zac Gallen (2-3, 2.58 ERA) makes his third start as a Diamondback and second of his career against the Colorado Rockies, who come to Phoenix for a three-game series.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports