Quits the handler thread's looper safely.
Causes the handler thread's looper to terminate as soon as all remaining messages
in the message queue that are already due to be delivered have been handled.
Pending delayed messages with due times in the future will not be delivered.
Any attempt to post messages to the queue after the looper is asked to quit will fail.
For example, the {@link Handler#sendMessage(Message)} method will return false.
If the thread has not been started or has finished (that is if
{@link #getLooper} returns null), then false is returned.
Otherwise the looper is asked to quit and true is returned.
Looper looper = getLooper();
if (looper != null) {
looper.quitSafely();
return true;
}
return false;