Check out the Socket:LingerState property.