Add close button to chats dialog

Also fixes build
Visible message limit feature

Also attempt to fix a bug with preferences page, but well... it's still
there.