Ensure close handlers are called when connections are closed