Close the door so you have access to the hinges without the door moving.
Pull out the top hinge pin from the door with a pair of pliers. Adding resistance to the pin helps prevent the door from closing itself in the future.
Place the pin on the ground or on a workbench and gently hit the center of it with a hammer to put a dent in it.
Slide the pin back down into the hinge. It will be tougher to get it into place because of the bend in the middle of the piece, so use the hammer to push it down if necessary.
Open the door and see if it still closes by itself. Do the same procedure for the lower hinge pin if it does and the problem should correct itself.
Tighten the hinges into the door frame itself with a screwdriver to add even more resistance to the hinges.