Fix connection leaks in exception code paths

Particularly when server is under extreme high loads,
it may throw RuntimeException, and in these exception
code paths, opened connections has to be closed
before returning the control to the caller.