Moved inactivity check to it's own loop.

Also removed the constant checking for closed IM windows.
Fixed silly typo in saveBot.