Should i be safe?

Last night I had unprotected sex with the pullout method with my partner he basically pulled out with time not at the moment but I was on my last day of my cycle. Should I take plan b or should I be fine? My next cycle doesn’t start until august 17. I already have an appointment for my iud on Tuesday…