The question is interesting and I think this question may be in minds of many others as well. So let me answer this question.
The answer is Yes and No.
Yes you can transfer a domain to other registrar even before few hours of expiry because normally the transfer of domains can be completed in few hours but at times the registrar from where you are transferring the domain out can take lot more time than actually needed. Normally transfer requests can be approved within 5 days and so if they take couple of days to approve the transfer (which normally should not be the case unless a holiday), you have the risk of loosing the domain.
So ideally you should be transferring the domain with few days of buffer in hand but if you still cannot get that done then you can possibly do a live chat at the current registrar and get the transfer approved instantly (almost ). This depends on your current registrar’s support.
My final verdict would be, unless it is a must, do not transfer the domain registrar in the last week of expiry.
If you are trying to move your domain from or to GoDaddy, Check out