SAN FRANCISCO -- The Cubs had scuffled offensively in their last series, they were facing two-time Cy Young winner Tim Lincecum on a cool night, and the Giants were trying to stay in the playoff race.
Who would've figured Randy Wells would end up with a shaving-cream pie to celebrate his first shutout or that Lincecum would serve up three homers?
Blake DeWitt belted a three-run homer and Alfonso Soriano, Geovany Soto and Carlos Pena each hit solo shots to help Wells finish August unbeaten as the Cubs roughed the Giants, 7-0, on Monday night.
Lincecum had given up three home runs in his 14 previous outings combined, so when Soriano connected to lead off the fifth, that appeared to be it.
"At 1-0, you figure that's the way it's going to end," Cubs manager Mike Quade said.
Wells (6-4) delivered a strong counter. He gave up two hits -- a double by Andres Torres with two outs in the third and a single by pinch-hitter Mike Fontenot with one out in the eighth -- and struck out seven. It's a good finish for the right-hander, 29, who had to go on the disabled list after his first start April 4 because of a strained right forearm.
"There's just no guarantee when you come back from something like that, especially when it's the first time [he's been on the DL], that you're going to be the guy you were before and sometimes it takes longer," Quade said. "He certainly has pitched well."
Wells didn't shake Soto off very much.
"We get in this [groove] where it flows," Soto said. "All the credit should go to him -- he made his pitches and didn't leave many balls up. That was good."
A pep talk earlier this season from teammate Ryan Dempster helped Wells.
"It was about being a good pitcher," Wells said. "It was kind of 'Quit making excuses and feeling sorry for yourself because your arm has been bothering you and pitch like you know you can pitch,' because whatever I was doing wasn't working. That was pretty much it."
He received a celebratory shaving-cream pie, his first since his first win.
"It's pretty fun," Wells said.
Quade told Wells prior to the ninth that he was sticking with the right-hander. Kerry Wood was up just in case.
"I felt like I was throwing the ball good enough and attacking the zone and could come away with three quick outs," said Wells, who notched his first shutout at any level.
The win was only the Cubs' second in the last nine games; they started August 11-3.
Lincecum (12-11) served up all but Pena's blast, and it's the first time in his career he has given up three homers in one game.
"We tried to make him work, tried to make him throw a lot of pitches," DeWitt said. "Runs are hard to come by against a guy like that and we were able to score a couple tonight."
The game didn't begin well for the Cubs as Starlin Castro doubled to lead off and reached third on DeWitt's grounder but was stranded as Aramis Ramirez flied out, Pena walked and Marlon Byrd grounded out on the first pitch he saw.
Soriano connected in the fifth, launching a 1-2 pitch into the left-center-field seats for his 23rd homer. Soto ended an 0-for-25 skid when he led off the seventh with his 14th homer to make it 2-0.
"That felt really good," Soto said. "I'm grinding, working with [hitting coach] Rudy [Jaramillo] and trying to be where I need to be and finish strong."
Wells walked and Castro reached on an error by shortstop Orlando Cabrera to set up DeWitt's blast, his fifth, and chase Lincecum.
"He's a great pitcher," DeWitt said of the Giants right-hander. "Runs are hard to come by against a guy like that. Wells stepped up and pitched about as well as you could pitch. ... He was locating everything, throwing right at guys and throwing strikes. That's all he has to do to be successful."
One out later, Pena belted an opposite-field homer off Steve Edlefsen, Pena's first to left this season. He did have two to left-center.
It's the first time the Cubs have hit three homers in one inning since June 9, 2010, when they did so against the Brewers. In the just-completed three-game series in Milwaukee, they hit two homers.
Byrd added an RBI single in the ninth after DeWitt tripled to lead off the frame.
For Wells and another young Cubs starter, Casey Coleman, every outing is a chance to prove they belong next year.
"You're auditioning every time you go out and play," Quade said. "[Instead of auditioning], I'd rather say that they're trying to find out who they can be. Randy, to me more than Casey, knows who he can be and has been that guy, and Casey is just trying to get better and be more consistent so he can pitch at this level. Both of those guys are obviously searching and working to get better."
Carrie Muskat is a reporter for MLB.com. She writes a blog, Muskat Ramblings, and you can follow her on Twitter @CarrieMuskat. This story was not subject to the approval of Major League Baseball or its clubs.