If the withdrawal was taken from an IRA account and you had not owned a primary residence for the two years prior to the closing date on this house, it would count as an exception to the 10% early distribution penalty on the $5,000. The money withdrawn would still be taxable income though.