exit correctly on failed authentication

This fixes the hanging behavior of backend.py when trying to connect to a router with authentication.