-- close the application correctly

Follow this procedure while switching the screens