  The first neutron star binary merger detected in gravitational waves,
GW170817 and the subsequent detection of its emission across the
electromagnetic spectrum showed that these systems are viable progenitors of
short $\gamma$-ray bursts (sGRB). The afterglow signal of GW170817 has been
found to be consistent with a structured GRB jet seen off-axis, requiring
significant amounts of relativistic material at large angles. This trait can be
attributed to the interaction of the relativistic jet with the external wind
medium. Here we perform numerical simulations of relativistic jets interacting
with realistic wind environments in order to explore how the properties of the
wind and central engine affect the structure of successful jets. We find that
the angular energy distribution of the jet depends primarily on the ratio
between the lifetime of the jet and the time it takes the merger remnant to
collapse. We make use of these simulations to constrain the time it took for
the merger remnant in GW170817 to collapse into a black hole based on the
angular structure of the jet as inferred from afterglow observations.
  We conclude that the lifetime of the merger remnant in GW170817 was $\approx
1-1.7$s, which, after collapse, triggered the formation of the jet.
