Certified GKH Gardening Expert
After they die off for the year, they should only be left for a week or two. You can leave them longer, but they could either rot, or start growing again. If it does start growing again, there is no harm in killing the growth, and eating the onion. Once it flowers, though, it may not be worth eating. This happens, usually, during the second year.
This article will help you to grow onions: https://www.gardeningknowhow.com/edible/vegetables/onion/find-how-to-grow-onions-in-your-garden.htm