Added exit 0 to end of script to ensure all threads are killed.