During perimenopause ovulation becomes irregular but does not stop entirely, so pregnancy is still possible even when periods are erratic or infrequent. Fertility is lower than in your younger years, but it is not zero.
General guidance is to continue contraception until 12 months after your last period if you are over 50, or until 24 months after your last period if you are under 50. A clinician can advise on which methods suit this life stage, as some also help with perimenopausal symptoms and bleeding.
If you are unsure whether you still need contraception, or your periods have become very unpredictable, talk to a doctor or family-planning service rather than guessing. They can advise on testing and the safest options for you.