For a beginner, how do you know when its time to leave the gym?
Like Ill finish my program/workout but usually feel like I want to keep lifting and that I have more energy in me. Not so much for small muscles but I feel like my back and legs for example are never fatigued enough to stop.
Should I keep lifting for over an hour until I literally cant anymore? Or just follow my routine?
Follow the routine. It was (hopefully) made by someone who knows his shit.
The volume and progression are the way they are for a reason and overdoing it is a good way to injure yourself.
Go until you tear something, then you'll have hit some fibres and you'll feel sore the next day