<s>[INST] Here is a piece of code in python:
```
import queue as q
from threading import Thread
from queue import Queue
import time

def producing(q):
    for i in range(1, 11):
        q.put(i)
        print(f"Producing {i}")
        time.sleep(1)

def consuming(q):
    while True:
        item = q.get()
        print(f"Consuming {i}")
        if item == 10:
            break

def main():
    q = Queue()

    t1 = Thread(target=producing, args=(q,))
    t2 = Thread(target=consuming, args=(q,))

    t1.start()
    t2.start()

    t1.join()
    t2.join()

if __name__ == "__main__":
    main()
```

This piece of code is trying to demonstrate producer-consumer problem. However the code has several problems. Please point out the issues and provide corrections.
There are several problems with this code:
- The variables i in the consuming function is not defined.
- The consuming function will only stop once it sees 10, which is incorrect. Since the producer will not produce any more items after 10, the consumer will end up blocking on q.get() call waiting for more items.
- The producer thread does not produce any more items after producing 10 items. The consuming function will end up blocking on q.get() call. 
- The main thread waits for both the producer and consumer threads. However it does not provide any way to handle the termination of these threads.

I have pointed out the issues with the code. My question is how can I correct these issues?[/INST]