Create script to disallow using Mac at night?
This is what Parental Controls can be used  for.

You can set the times where you can and cannot use the computer.  The caveat is that you cannot be an Admin so you will need to give the reins of control over to a trusted person.

That said, Parental Controls is just one avenue and you cannot rely on tech to address an issue like this.



I say this with the utmost sincerity and with nothing else than the stated goal of seeing you helped:  

This is symptomatic of an addictive behavioral disorder and can be something that is very difficult to overcome.  In addition to the tech blocks, I highly suggest you seek out a licensed therapist.