Although a very basic thing, but when I actually started writing the code and made dry runs, I faced two basic challenges: identifying appropriate locators and disabling browser level notifications. But after numerous trials and errors, I was finally able to strike the right chord.
Thanks for the comment Aishvarya. I wrote this script a few months back and since then there have been some changes in Facebook UI. So following your comment, when I debugged the script I found the issue as:
Turns out that Selenium was not able to find the Log out button. So when I checked the Facebook UI the previous Log out was changed to Log Out (O in caps). I have made the changes, and now the script runs fine.
Go to Facebook Page Source (Right Click -> View Page Source) and search for ?xhpc_message?. You will find it as the name for the facebook status box (text area), which we are using in our code. Look into the image for more clarity: