Headlamps not function correctley

I have a 1999 Toyota 4Runner V6 Four Wheel drive with 140000K. While driving at night both headlamps turned off. I replaced the headlamp relay located in the engine bay, checked all the other fuses and unhooked the battery cables then reconnected. Now the headlamps are staying on when I turn the engine off and off when the engine is turned on. Can you please help me figure out what seems to be the issue. Thank you.

It seems that the relay is getting a signal to stay energized when its not supposed too. Perhaps from the headlight switch or a wiring problem. If it was me I would test that old relay (just so I knew I was on the right track, no chance you put a incorrectly rated relay in the slot and now its damaged?)