URL redirection and close the session

Hi, I need to redirect to redirect url and is not working.
In the documentation there is an example how close a session and redirect to a URL with the following code:

// Redirect from the page
getUI().getPage().setLocation( “/book-examples-vaadin7/closed.html”);
// Close the VaadinSession
getSession().close();

but my method does not work with the following code:

public class ValidarTicket extends CustomComponent {

public ValidarTicket(Button completar, Button continuar, Button abortar, String numTk, String numInst, String numClass){
    IAutenticacionserviceLocator Locator = new IAutenticacionserviceLocator();
    IAutenticacionbindingStub myStub = null;
    

        try {
            myStub = (IAutenticacionbindingStub) Locator.getIAutenticacionPort();
        } catch (ServiceException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        
        int numInstInt = Integer.parseInt(numInst); //convierto de string a int
        boolean valid;
        try {
            valid = myStub.verificarSesionActivaPecas_V2(numTk);
            try {
                System.out.println("El Ticket: "+valid);

                if( valid == false ){
                    //mostrar un mensaje de error por el formulario
                    Notification.show("El Ticket de la tarea no es correcto");

                    // Redirect from the page
                    getUI().getPage().setLocation("/book-examples-vaadin7/closed.html");
                    // Close the VaadinSession
                    getSession().close();
                    
                    }
                else{
                    EjecutarTareasWF soli = new EjecutarTareasWF(completar, continuar, abortar, numTk, numInst, numClass);
                    //mostrar por el formulario un mensaje de éxito
                    System.out.println("El Ticket Es Correcto ticket validado");
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            
        } catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
}  

}