Gattis homered twice, Castro threw out a runner to end the game and the contending Astros beat the Oakland Athletics 6-5 on Wednesday to complete a sweep.
"Just trying to finish strong," said Gattis, speaking both of himself and the Astros. "You don't want to limp out of the season. You kind of want to sprint, you know?"
Houston has been sprinting ever since a 1-6 stretch that ended Sept. 13.
The Astros, who began the day two games behind Baltimore for the second AL wild-card spot, have won five of six since then.
They had to sweat out their latest win after giving up an unearned run in the ninth.
Oakland scored on second baseman Jose Altuve's fielding error with two outs to pull within 6-5. Castro then threw out pinch runner Arismendy Alcantara trying to steal second, and the call was upheld on a replay review.
"I don't think (Alcantara) got his best jump on that one but that's what he's in there for and Castro made a good throw," A's manager Bob Melvin said.
Collin McHugh (12-10) won his fifth straight decision, allowing two runs and six hits over 5 2/3 innings. Five relievers combined to record the final 10 outs, with former A's setup man Luke Gregerson retiring three batters for his 15th save.
"We just need to beat the teams that we should beat, and I think this is one of them," Gregerson said. "We need to keep winning, keep us in the wild card and hopefully keep getting bumped up."
Gattis reached 30 homers. He hit a two-run drive in the sixth off Daniel Mengden (2-8) for a 4-1 lead and connected again in the eighth.
Carlos Correa had two hits, including an RBI double, and Altuve singled twice and scored a run. Gattis homered for third time in three days to finish the three-game sweep.
"Really just trying to stay inside the ball and behind it instead of trying to come around," Gattis said. "There are a lot more outs at the end of the bat."
The Astros scored their first run without a hit in the fifth and added three more in the sixth.
Altuve, the AL's leading hitter, had a one-out single and scored the go-ahead run on Correa's double. Gattis followed with a home run.
Gattis' homer in the eighth was a towering shot that hit off the fa�ade underneath the luxury suites in center field.
Danny Valencia singled and scored twice for the A's. Oakland has lost the first three games on its final homestand after an impressive 6-1 road trip.
MENGDEN WEARS DOWN
Mengden needed only 26 pitches to get through the first three innings and didn't give up a hit until Yuli Gurriel's one-out single in the fourth before things quickly unraveled. He allowed four runs over 5 2/3 innings with seven strikeouts and two walks.
McHugh won for the third time in four starts this month and improved to 11-0 in September since 2014.
Astros: OF Colby Rasmus missed his third straight game because of "a lot of different" physical issues, according to manager A.J. Hinch. Rasmus missed 23 games earlier this season after undergoing surgery to remove a cyst in his right ear. ... Preston Tucker was scheduled to undergo season-ending surgery on his right shoulder Wednesday and the team is confident the outfielder will be healed in time for spring training.
Athletics: OF Khris Davis missed his second straight game after being a late scratch Tuesday because of an illness. ... Reliever J.B. Wendelken will seek a second opinion on his right elbow but Melvin indicated it's likely Wendelken will undergo Tommy John surgery.
Astros: RHP Mike Fiers (11-7) faces the Angels in Anaheim on Thursday in the opener of a four-game series. Fiers has a 4.06 ERA over his previous 19 starts.
Athletics: Kendall Graveman (10-10) starts against Texas on Friday at the Coliseum. The right-hander is winless since Aug. 24.
Ranking Angels star Shohei Ohtani's greatest hits -- and pitches -- of the 2021 MLB season
The Angels' two-way star is headed to the Home Run Derby. Here's our running list of his five best moments, both at the plate and on the mound.
Fantasy baseball forecaster for Week 12: June 21-27
Set your lineups for the week ahead in fantasy baseball with our forecaster preview, which features pitcher rankings, two-start pitchers, hitter ratings, schedule observations and more.
Every one of Shohei Ohtani's 19 HRs this season
Enjoy Shohei Ohtani's 19 home runs this season as he commits to this year's Home Run Derby.
Los Angeles Angels' Shohei Ohtani becomes first player to commit to Home Run Derby
Los Angeles Angels two-way sensation Shohei Ohtani announced Friday that he will participate in next month's Home Run Derby, becoming the first player to commit to the event.
Fantasy baseball daily notes: Pitcher and hitter rankings for Saturday
Prepare your fantasy baseball lineups confidently with our daily preview, including pitcher projections, hitter matchup ratings and more.
Fantasy baseball forecaster: Team hitting ratings
Stay ahead of the game and optimize your fantasy baseball hitters with our forecaster, which provides a rolling 10-day outlook of every team's hitting matchups as well as the potential for stolen bases.