Should I finish all work that I started before PhD graduation? I have enough work done for my PhD dissertation, but I also have one on-going project which I don't plan to include it in my dissertation. My advisor suggests that I have to finish all the work before I graduate. Is it so? 

My advisor doesn't currently have funding and I am not being paid now. He also wants me to share my codes with him and other students, should I do so?    I don't quite want to share my work because 1) I was not be paid; 2) I wrote the codes totally on own and didn't receive any technical helps from my advisor (my advisor is a good story-teller, but he barely knows anything concerning technologies). Am I thinking correctly?
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.