Fix issue where modal breaked on close method