The short answer: as soon as the deal is closed. Many people have the mistaken idea that they have until midnight, or until 6pm, but neither of those is true. Once the transfer is registered, you are technically trespassing if you’re still there.
The long answer, however, is that many sellers aren’t quite out at closing because they’re moving to a new house, and most buyers are understanding as long as your packing is in progress and you are getting the house empty.
When you sell, try to be packed and ready to go, because once that transfer happens, you need to get moving.