I only do that when the problem space is interesting.
Most developers are just implementing CRUD using a framework that does most of the work. There isn’t the interest motivation to keep on trying to fix things.
My job involves going out to sites to install equipment sometimes. This means as long as I’m walking out with a box in my hand I can leave whenever I want. My boss doesn’t care where I am as long as things get done.
Who isn’t racing out the door at 5pm? I trade labor for wages, I’m not sticking around for unpaid overtime just to make some investor who’s never worked a day in his life even richer.