Fix #5 detach when window lost focus