The in-form Millers grabbed the winner in the first minute of injury time when Dan Barlaser's ball in found Wiles who headed home.
The first half was largely forgettable in terms of chances with the best falling to Stanley after 24 minutes.
Dion Charles raced clean through, keeper Daniel Iversen missed the ball but Matthew Olosunde produced a last-ditch sliding tackle as the Stanley striker lined up to shoot into the empty net.
The game burst into life with two goals in a minute after the break.
With 64 minutes gone Barlaser corner's found Michael Ihiekwe at the far post, he headed the ball back in and sub Freddie Lapado, on for three minutes, forced the ball over the line.
A minute later, Sam Finley got the ball on the left wing and found Jordan Clark who rifled home his eighth goal of the season to level the scores.
Wiles headed home but Offrande Zanzala missed a superb chance to level again for Stanley, heading over unmarked six yards out.
Matt Crooks hit the bar for the Millers in the sixth and final minute of added time.