Add handler for hiding the error messages while navigating away

Fixes #272