Fix crash when unplug the mouse with pointer in the window.

We should not only call OnSetCapabilities after we create input
but also call OnSetCapabilities before we destroy them.

BUG=250