PWM and fan not working correct

Hi guys,
I hooked up a 12V fan (2 cable type 0.2A) with a 12V external battery, a IRF540N MOSFET and a 1N5817 schottky. The DOS shows me, that the PWM is working correct. The fan starts up spinning slow, gaining speed, up to full speed. The problem is that the fan keeps on going at full speed, even if I pull the PWM pin.
However without the PWM pin connected, the fan wont start up. (I guess thats the only normal reaction XD)

Thanks for any help

even if I pull the PWM pin.

If you only have two wires to the fan how do you pull the PWM pin?
Or is that the pin to the gate of the FET leaving it floating? If that is the case then yes it will keep on spinning because of the charge on the gate. Have you commoned up the ground of the arduino and the ground of the 12v supply?

Yes, the PWM pin connects to the gate of the FET. No, the arduino ground is not commoned with the 12v supply. Please take a look at the attachment.

No, the arduino ground is not commoned with the 12v supply.

Well, then, we seem to have found the problem.

You could also put a pulldown resistor from gate to ground to ensure the MOSFET is turned off when the arduino starts up and the output 'floats' as an input until you set it as output and then bring it low to the off state.

Indeed, it works!
CrossRoads, Im going to pick up your idea and hook up a pulldown resistor.
Problem solved - thanks for your help.