fix double free on app exit

this fixes the following segfault on app exit:
http://paste.ubuntu.com/8557971/

Not 100% sure if its the proper fix, so please review/test :)