Remember that your ‘need’ for caffeine, a stimulant, is mainly driven by your ‘need’ for sleep.
Also, your ‘need’ to use a depressant such as alcohol before bed is often driven by the overuse of the aforementioned stimulant.
Our body is the grandest of complications.
Every cell has its own mechanism. A timer if you will that is set to start at a prompt, initiate a series of actions and assuming the prompt remains constant repeat.