Added CloseWindowOrKillBuffer function.