Hei Rohit,
you can only logout
from a shell where you really logged yourself in with username and password (or key e.g. on ssh).
It won't work in xterm as you allready logged in to the Xorg session via a login manager or from a terminal where you ran startx
after you logged in via username and password.
Say you are on ttyv0 and enter your username and password, you should be able to logout via logout
not matter what shell you are using.
But if you start another shell on top of that shell, the new shell isn't a login shell anymore and logout
will not work.