Merge from AdAway: Properly close streams

Close streams after shell process termination. This fixes some
ANRs/crashes while doing root operations (at least on some
ROMs/Superuser solutions). These changes may require testing on other
ROMs/configurations. Changes introduced:
* Wait for shell process exit before closing stdin
* Reduce CPU usage (by 50 ms delays) while waiting for new commands
* After shell process exit close stdout/stderr

The changes are exactly the same as in this commit to RootCommands in AdAway repository:
https://github.com/dschuermann/ad-away/commit/2338b6d5c4f2bbfd66686ba1231bfb39d3d0e3b6