Isn’t it grand? Royals win in 10

? If this was the last swing of the season at Kauffman Stadium, it was one to savor.

Justin Maxwell ended the Kansas City Royals’ home season with a two-out grand slam in the 10th inning Sunday for a 4-0 victory over the Texas Rangers in a match-up of AL playoff contenders.

“I kind of blacked out after I looked at Gordo (Alex Gordon) over there going crazy,” Maxwell said. “I just saw the excitement in all my teammates’ eyes. I couldn’t wait to get around the bases and to home plate.”

The Oakland Athletics clinched the AL West with the Rangers’ loss.

Texas dropped 11/2 games behind Cleveland for the second wild-card spot. Kansas City is 31/2 back.

Maxwell connected off former Royals All-Star closer Joakim Soria.

“I’ve never faced him before,” Maxwell said. “With a 3-2 count, bases loaded, two out, I was just looking for a fastball strike and I got one. I didn’t try to really do too much. Paralysis by analysis. I try to dumb it down and try to hit the ball hard.”

Soria knew he couldn’t afford to throw a borderline pitch and have the winning run score on a walk.

“I had to throw a strike in that situation, and it couldn’t be close,” Soria said.

Royals starter James Shields gave up six hits in eight innings, walking one and striking out two.

Texas starter Alexi Ogando pitched two-hit ball for seven innings, striking out five and walking one.

Eric Hosmer led off the Royals 10th by punching a double with two strikes down the left-field line off Neal Cotts (5-3). Soria relieved and intentionally walked Billy Butler, and an infield single by Salvador Perez loaded the bases.

Mike Moustakas popped up and pinch-hitter George Kottaras grounded into a force play at the plate before Maxwell’s grand slam.

Tim Collins (3-6) worked a perfect 10th to pick up the victory.

Ogando, who had three stints on the disabled list this season, excelled in just his eighth start since May 15. He left after 77 pitches.

“I thought overall it went very well,” Ogando said through a translator. “I was really able to locate my pitches and able to

throw them for strikes. You know what’s going to happen if you can throw strikes where you want and be able to be aggressive with your pitches.”

Maxwell hit a leadoff single in the third and moved up on a sacrifice, making him the lone Royals runner to get past first base off Ogando.

Shields, who was 4-1 in his previous five starts, lowered his ERA to 3.21. He was struck in the right elbow by David Murphy’s liner in the second, but remained in the game after making some warmup tosses as manager Ned Yost watched from the mound.

“You can probably see the big bump in my elbow,” Shields said. “I had a hard time feeling the baseball the whole rest of the game. It’s just one of those games, one of those moments where I wasn’t coming out of the game. I told Skip I wasn’t hurting. I wasn’t necessarily feeling good, but I felt fine to go back out. It was kind of tightening up between every inning.

“Ogando pitched his heart out and it was just fortunate we got the win. The fans were unbelievable. It was electric in the stadium as I’ve ever seen it. They were into every single pitch,” he said.

Shields allowed two-out singles to Ian Kinsler and Elvis Andrus before getting out of the inning.

Royals closer Greg Holland took over in the ninth. Alex Rios made it to first when he struck out on a wild pitch to lead off the inning and stole second. But Rios was thrown out trying to take third on Adrian Beltre’s fly to left, with Gordon getting his AL-leading 16th outfield assist.

“Rios was trying to make something happen, which you can’t blame him,” Gordon said. “I was just trying to make the play, keep the score zero-zero and help Greg out. Alex Rios is a long strider, very fast, so I had to make a good throw. That’s what I planned to do. I didn’t do much all day, but that was key.”

Perez helped out Shields by throwing would-be basestealers Andrus at third base in the first and Leonys Martin at second in the fifth.

“Stealing third is easier than stealing second for me,” Andrus said. “He throws well. I took my chances. That kid Perez is amazing. It’s pretty tough the way they play defense. You have to tip your cap.”

Notes: The Royals’ final home attendance was 1,750,754, an average of 21,614 for 81 games. The Royals averaged 21,748 for 80 home dates last year. … The Rangers play their final seven games at home. LHP Derek Holland, who starts today against Houston, has lost five straight decisions at Rangers Ballpark since May 31. He is winless in his past eight starts, the longest drought of his career. … The Royals, who finish up with seven games at Seattle and Chicago, are 38-36 on the road. They have not finished above .500 on the road since going 43-39 in 2003.