Fixed shared state refcount bug in fm.c

Missing '!' in fm_CloseState() caused a memory leak, and with multiple
states, it would most likely have caused segfaults.