Remove the bottom hinge pin. Place a pin punch or nail on the hinge pin and gently tap on it until it pops out of the top of the hinge.
Locate a hard surface and pound the hinge pin until slightly crooked. Using your hammer, pound the pin in the center. You want to bend the pin roughly 1/8-inch, but no more than that.
Place the bent hinge pin back in the hinge. Make sure the two parts of the hinge are aligned, then tap the hinge pin back into to hinge.
Check your door. Test it to see if it stays put and doesn't swing open. If it still swings open slightly, repeat Steps 1 through 3 with the top hinge.