According to documentation, the GAP_EVT_ADV_SET_TERMINATED event is "Sent when an advertisement set is terminated due to a connection establishment."
But actually the event is also sent when advertising is terminated due to timeout (which is perfectly fine by me). In that case the connHandle field of the parameter struct has the (undocumented) value 255.
Wouldn't LL_CONNHANDLE_INVALID (0xFFFF) be more appropriate here?