It will depend on the restaurant so check the dining reservation page for the restaurant and date you are interested in. It will indicate the last available reservation time for that day.
If the park is closing at 6 PM there is probably a special event (e.g Halloween or Christmas party) or a private event in the evening in which case the last available reservation time for day guests will vary. Last year on party nights at the MK some restaurants that were not open during the party had reservations until closer to 7 PM. For TS restaurants open during the party (e.g. CRT, BOG) there was the regular restaurant reservation page for pre-party times and a separate reservation page for later reservations that required party tickets. If the park is having a private event, the reservation cut off time might be early enough for all day guests to be out of the park by 6 PM.