some fix on closing connection