Add the close functionality to the error handler