529 Non-qualified withdrawal taxes

My son has graduated college and I'm fortunate enough to have a 529 surplus.  I'm interested in withdrawing the balance of the account but want to make sure I understand the tax implications first.  It's my understanding the earnings portion will count as ordinary income with an additional 10% penalty.  For example, if the earnings portion is $40K then that amount is included with my other income to calculate my tax liability.  Once that number is known, an additional $4K (10% of $40K) is added to determine my total tax liability.  Is my thinking correct?

Thanks

Gary