The answer for this one was:
After I have clicked on a button shutdown
and the log-out screen has shown, I pressed the esc
key and I could see the error text messages, and I have found the message:
Waiting for Redis to shutdown ...
After finding out what script is used to shutdown Redis, I have found out it is:
/etc/init.d/redis_6379
When I tried manually to shutdown manually from console running a command:
sudo /etc/init.d/redis_6379 stop
I got the same error message. I was one step closer to the solution.
Even though maybe the solution was not as perfect as it could be, but I managed to solve my problem. I have edited the file:
sudo gedit /etc/init.d/redis_6379
And found the:
echo "Waiting for Redis to shutdown ..."
Edited the surrounding code (commented out some lines and added one other command to shutdown the Redis server)
/etc/init.d/redis-server stop
#while [ -x /proc/${PID} ]
#do
echo "Waiting for Redis to shutdown ..."
#sleep 1
#done
And whola! The Ubuntu now will not stuck in an infinite loop, and now I could shutdown, suspend and restart again! :)