Fixes #913 by disassociating applications on deletion.