I strongly suggest that you finished your work or projects first to avoid overstaying at night. Also do a better time management, it can save your health a lot. Trust me, it's not good staying overnight.
Having a regular day job and a side project for extra income sometimes require to work until late at night. But you are right that staying overnight is not good because it could result in different health problems.