Should I finish all work that I started before PhD graduation?
If you are not being paid, you should not be spending your time on a PhD.  You should tell your advisor you are not able to continue without financial support.

It is your advisor's job to recommend what you should include in your thesis.  Nobody who has not read your work will be able to advise you on this.

You want to keep the code you have written secret.  To determine if you can do this, you need to consult your university's intellectual property policy.  Very likely the policy says the university owns the rights to all your work, in which case you should hand it over.  In any case, keeping secrets when secrecy is not an ethical requirement is poor scientific practice.