I did this a lot this year, usually until 3am every night. I’m a remote worker who works and games at the same desk and chair. Often I would lie to myself about being productive and then quit a tutorial after a few minutes and load up a game instead. I found I stopped since about September, mainly by telling myself nothing really productive happens after 11pm and to just go to bed.
I struggled with this exact thing. For me personally I was able to focus better by dual-booting my machine so that my personal desktop/storage/workspace was distinct from my work stuff. Currently I have a work laptop I use on the same desk and I turn off my personal machine during the work day.