Aerobic exercise causes the body to release endorphins.These chemicals can create a level of activity in the brain that keeps some people awake. These individuals should exercise at least 1 to 2 hours before going to bed, giving endorphin levels time to wash out and “the brain time to wind down,” she says.