Finish close-window script