Added finally to prevent deadlock

lock.unlock was moved nto finally block, so when an exception occurs
during message broadcasting, a deadlock is avoided