Create a common method for the closing of current dialog box

GCP-10227

Reviewer: Mae Isabelle Turiana