This is called stimulus control, and it's a standard part of the insomnia treatment with the best evidence. Evidence: solid
The idea behind it: your brain learns by association. Hours of lying awake teach it that bed is a place for being awake. Getting up breaks the pairing. That theory is widely accepted but hasn't been proven directly. Evidence: decent
Don't watch the clock. Estimate. Clock-checking itself keeps you up.
Same theme: In the night