There is no limit when you can cancel your subscription. Even if you cancel just a few minutes before the renewal payment, the payment will be stopped immediately, your subscription cancelled and you will not be charged.