Refactor title bar to independent module. Hook up title bar close button.

This still needs cleanup.