Yes, you can generally enter a line que right up until closing time...however, there can be the rare occassion when there may already be a long line already in the cue and it may be closed off earlier.
For example, at Safaris, while the park may close at 5 the entry is usually roped off at 5 and those remaining guests already in the cue are cycled through....but I've seen occasions during busy seasons where there may be a long wait time at the end of the day.....say for example a 45-60 minute wait, and on occassions like that a line
may have to be roped off earlier (perhaps 4:30-4:45) in order to accomodate those already in the line and cycle them through the ride.
but, to answer the question directly...yes, if you are already IN the cue, you will get to ride
