So basically this is happened, I got to the end thinking I was still on track to get the genocide ending, but then I fought Asgore and then the game ending with Sans calling me and telling me to go to Hell, and instead of the game restarting like normally it goes back to right before the final boss fight (against Asgore), and it just keeps looping this fight against him again and again. I'm also pretty sure I'm not supposed to fight Asgore here in the genocide ending. I realized that there were still some monsters left in multiple areas (currently trying to clear out Snowdin, there might be more elsewhere). If I go back and kill all the monsters can I still get the Genocide ending?
I'm afraid you have to re-do a run from scratch as you may have aborted it by missing monsters.
Remember that you have to kill a certain amount of monsters before fighting one area's boss:
- 20 kills in the Ruins before fighting Toriel
- 16 kills in Snowdin before fighting Papyrus
- 18 kills in Waterfall before fighting Undyne
- 40 kills in Hotlands/Core before fighting Mettaton
Sparing a single enemy will abort the genocide run, fleeing won't.
Minibosses can count as a kill (the dogs in Snowdin, Glad Dummy in Waterfall, Royal Guards and Muffett in Hotlands, the monsters from the path of the fighter in the Core)
You know you're still on the genocide route if you check save points and have either a remaining monsters count or "Determination" as a response
Good luck and have fun