add previous url into the close window button and improve the get_previous_url method in BaseHandler