I made the following modification to finish.m such that my startup.m - which already contains important data - is not overwritten:
%%%%%%% finish.m %%%%%%
str = pwd;%store present working directory in the variable str
% figure out where to put restorewd script
pathstr=userpath;
if(isempty(pathstr))
pathstr=[matlabroot filesep 'work'];
else
pathstr=pathstr(1:find(pathstr==pathsep)-1);
end
fid = fopen(fullfile(pathstr,'restorewd.m'),'wt');%open file for writing
fprintf(fid,'answer = questdlg(''Do you want to continue working in the previous working directory'',''Restore Last Working Directory'',''Yes'',''No'',''Default'');\n');%write this and the following 3 lines into restorewd.m
fprintf(fid,'cd(''%s'');\n',str);
fprintf(fid,'end');
fclose(fid);%close file
%fprintf(fid,'end');
fclose(fid);%close file