Draw a spacetime diagram. Really, there is no better way to solve relativity problems.
In the above, the nail has worldlines $1$ (back) and $2$ (front), while the hole's worldlines are $3$ (front) and $4$ (back). Let's agree that the origin $\mathcal{O}$ of the coordinates is the event of the front of the nail just entering the hole, i.e. the intersection of worldlines $2$ and $3$. Also, all my coordinates are in the order (time, space), with space on the horizontal axis, and the speed of light has been set to $1$.
In the frame of the hole (diagram on the left), the back of the nail is a distance $l/\gamma$ to the left when the front enters (event $A$). Since the worldlines of the nail are at an angle $\theta = \sin^{-1}(1/v)$, we can easily find the time at which the back of the nail reaches the hole, $l/\gamma v$ (event $B$). At this point, information that the back of the nail has been stopped travels at the speed of light ($45^\circ$ dashed line $BC$) to the front of the nail, no faster, to tell it to stop (event $C$).
Since line $\mathcal{O}C$ has formula $t = x/v$ and line $BC$ has formula $t = x + l/\gamma v$, we know the $x$-coordinate of $C$ is
$$ C^x = \frac{l}{\gamma(1-v)} = l \sqrt{\frac{1+v}{1-v}}, $$
which for any $l$ can be made arbitrarily large by making $v$ arbitrarily close to $1$. That is, we can choose $v$ such that $C^x > L$ and in fact the collision of the front of the nail with the back of the hole (event $E$) happens before the nail stops (unlike as drawn).
A similar analysis could also have been done in the nail's frame, as shown in the diagram on the right. We know $\mathcal{O}B$ has formula $t' = -x'/v$ and worldline $1$ has formula $x' = -l$, so the front of the hole reaches the back of the nail at time $B^{t'} = l/v$. Then information propagates up the nail along $BC$, with formula $t' - l/v = x' + l$, so the front of the nail knows about the back collision at time
$$ C^{t'} = l (1+v)/v. $$
Meanwhile, the back of the hole reaches the front of the nail at time
$$ E^{t'} = L/\gamma v. $$
The bug will be crushed if and only if $E^{t'} < C^{t'}$, which turns out to be exactly equivalent to the condition $C^x > L$.