Improve connection close socket code, destroy the tomcat container when stopping instead of exiting brutally.

Before this change when tomcat was stopped (in non daemon mode) System.exit(1) was called causing the gradle daemon to exit although we only want
tomcat to stop. I think this was done because the ports were not released by tomcat because tomcat.destroy was not called when
stopping.

Right now we call tomcat.destroy() after stopping thus releasing the resources and allow gradle to run in daemon mode.
When tomcat runs in daemon mode it shouldn't be treated differently from when it runs in non daemon mode so it is stopped by the same mechanism.
Merge remote branch 'vladvoic/master'
Minor formatting changes.