It depends on the API in use. For Java and C#, the connections are closed once the object memory is freed. However, with a client that doesn't control the connection, like JavaScript, the browser will keep the connection open for a period of time after it becomes inactive.