I had a look in the grammar book that you referred to, but it does not make the distinction with "habits". Even the example sentence in the book, ご飯を食べるとき手を洗う, would normally be considered a habit, no?
Another example sentence in the book is "私はシカゴへ行くとき車で行く", where the two actions obviously occur at the same time. For the "right before" meaning, the book does say that it applies when S1 is not a movement verb, but for this other example, the book says "When action 1 and action 2 take place simultaneously".