Use event BufLeave instead of BufWinLeave to record screen state to avoid undefined b:NERDTree error

Use event BufLeave instead of BufWinLeave to record screen state. The BufWinLeave event also triggered when exiting(:qa), will cause an undefined b:NERDTree error.
Merge pull request #356 from alvan/patch-2

Use event BufLeave instead of BufWinLeave to record screen state