Fix crashing when initializing router after navigation