Fix bugs about closing HttpURLConnection.