fix the bug of appescaping about window not closing
add test case for #984
Merge pull request #1020 from richardcypher/nwinmem

[test]add case for #984