Tap it with a hammer forcing the nail out the top of the hinge.
How to fix a door hinge that keeps closing.
On the latch side a door is cut at a slight bevel to make it easier to close.
When i say slight that means a barely noticeable bend.
If not align the hinge knuckles and tap the pins.
If your door has only two hinges close.
Use a screwdriver to tighten the screws attaching the hinges to the door and the door frame.
Open the door and check that the hinge pins are seated all the way within the hinge.
If one is loose remove two or more screws and try driving in longer screws.
Remove the pin by placing a screwdriver under the middle hinge.
Place a large nail or small screwdriver on the bottom of the center hinge pin of your door.
The easiest fix is to remove your middle hinge pin and put a slight bend in it.
The door should no longer move itself.
Work your way from the top of the door to the bottom.
Take a hammer and long nail and tap the pin gently from the highest hinge.
By bending the hinge you have increased the internal resistance within the hinge so it keeps the door from moving as easily as before.
How to fix a door that swings shut.
If you have a really crooked frame and still need just a little more resistance remove another hinge pin and perform the same magic.
Adjust the hinge to have it align correctly and snugly with the door and frame.