Fixed mousedown and window closing bugs