According to the current information posted on the ETS website, you need to cancel your test at least four days prior in order to receive a 50% refund. If it's three days or less before your test, you won't receive any refund.
To read about it in more depth, scroll down to the heading "Refunds" on this page: https://www.ets.org/toefl/ibt/about/fees/