penalty for 529 withdraw due to scholarships recieved in first 3 years

My son is graduating May of this year. There are unused money in his 529 account because he received tax-free scholarship all four years. I know I can take distributions to myself and  pay tax (use line 6 of form 5239) on earnings for the amount of scholarship he received in senior year. Can I also withdraw before May the amount of money equal or less than the total scholarship he received in the first 3 years, and avoid the 10% penalty?