You can cancel your subscription at any time by going to the Subscription & Billing section found in your account Udacity Account Settings, then click Cancel on your active Nanodegree program.

From there, you will be guided through some prompts in order to complete the cancellation. When your cancellation has been processed, you will receive a confirmation email.
-------------------------------------------------------------------------------------------------
In addition to this, we always recommend you to cancel your automatic subscription a couple of days before your next billing date in order to avoid being billed for the next period's fees.
Post the end of your refund period, if you cancel your subscription from a Nanodegree program, single paid course, or executive program, you will continue to have full access to the classroom content until the end of the current period. There is no refund for the remaining period of the month in which you cancelled. For more info on static content access, please click here.
As soon as you are ready to graduate i.e, when all of your projects are reviewed successfully, before your next billing date, you won't be charged further. Post which, once you graduate, you will continue to have static access to the content of your Nanodegree program. For more info on static content access, please click here.