Serial Port Closure with Pyfirmata+Pyserial

Hello all,

I made the mistake of disconnecting the Arduino while a seriously long script was running, via Pyfirmata. Now, any time I try to connect the Arduino again, and open the relevant serial ports to interface with it, it tries to do what it was doing before - applying a voltage to a digital pin, and checking to see whether one of the analogue pins has reached a certain value - and nothing at all can stop it. I've tried reset button mashing and such, and of course, calls such as board.sp.close(), but none of them work.

How do I terminate the serial port? Any ideas?

Even ignoring Pyfirmata, if I just import serial, then ser=serial.Serial('USBetc'), the process begins. ser.close() should sort this out, but it doesn't.

Thank you in advance, this has been driving me crazy for days.