I was just reading that after you die the spirit is returned to God. If the spirit returns to God will that be considered going to heaven or does it mean the spirit will be at rest until judgement? According to the Bible it is a sin to kill yourself. If one should kill themselves, where will their spirit go?
Answer
Perhaps the answers to your questions can be found in the difference between the soul and the spirit. For that, see my answer at What Does the Bible Say About..The Difference Between the Spirit and the Soul. Basically the spirit (breath, life force) goes back to God and the body goes back to the dust, as stated in the passage to which you refer (Ecclesiastes 12:7). The soul (person), on the other hand, awaits the final judgement, when it will be sentenced to eternal punishment or given an eternal home in heaven with God.
If this is the correct view of the difference between spirit and soul, then even the spirit of a suicide goes back to God. Whether God can forgive one who kills himself is a different question, which would affect the soul, not the spirit.
You say the Bible says it is a sin to kill yourself. It would be nice to find that in the Bible, but you can not. The Bible says it is a sin to murder. It may even say it is a sin in most, but not all, cases to take a life. Generally suicide is a premeditated taking of life, and therefore a sin of murder. So it can be assumed that taking one’s own life is a sin, but it is never directly stated. For a further analysis of what happens to the soul after suicide, see my answer here.