Thats right, the problems happens near closing time.
The issue with ASAP is it adds the interval maybe 15 or 45 to the current time, so if the current time is 23:25, ASAP will be 00:10, which will be outside the open/close hours. So maybe setting the interval higher or lower will help.
You can change the interval Globally from Admin -> System -> Settings under Order Tab in Delivery Time field and also locally for specific location from Admin->Locations->Order tab