Added null check on thread join

An exception was happening if the service died before the mainThread got saved.