Fixed flickering when closing a modal