echo "Checking mail queue and fetchmail process"
while ! postqueue -p | grep -q empty && ps -C fetchmail > /dev/null; do
echo "There is still mail in queue or fetchmail is still working"
sleep 1
done
echo "Terminating the connection"
killall wvdial