I have some recipes, that took quite long to cook, for example 8 hours. I want to start cooking those in the morning, so it is ready after I come from work in the evening. Is it safe to cook it on the gas? I put it on the smallest flame, so the amount of gas is very low. Are there generally any risks of some accident, or is the amount of gas so low, that when I open a window, the gas will be dissolved (in case that it would stop burning at some point in the process of cooking)?
Assuming your're talking about natural gas (methane) then unlike some other gases such as LPG it is less dense than air and will tend to float up. While in the case of a leak much would probably go out the window I wouldn't consider leaving it unattended 100% safe and can think of a few situations that could occur:
The remaining gas could accumulate between the top of the window and the ceiling. You probably won't be able to smell it but air turbulence from opening doors etc could cause it to circulate downwards and cause a hazard. Things like a small spark in a light or ceiling fan could ignite it as well.
Gas regulators can fail open, so as the regulator ages or if defective a small surge in the gas pressure for example might cause the flame to become much larger than you set. That would't be a good thing if you're not around to keep your eye on it.
Instead I'd probably go with a slow cooker as a few people have suggested in comments. It will vary by brand / size but my slow cooker uses 120 watts on the low setting. Over the eight hours of cooking that would use around 1kWh of power, costing under 20 cents for most of the United States so they are quite economical as well.