handle corner cases when done button is clicked.