Correctly close div's in modal popup