This is simillar to this question , but I'm not using NERDTree , instead netrw for same purpose. I have tried tweaking the script in my .vimrc a little bit , but I have no idea what do netrw buffers are named as.
With NERDTree this went well , but having tough luck with netrw.
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
Thanks :)