Also, stop the connection before closing it.