Fix some bugs.

Fixed bug on close app crash.