Collapse navbar if necessary

Since we're preventing the default action (which collapses the navbar),
we must manually do it in the cases that it's expanded.