Set up destroy hooks for Doorkeeper::Application

Trigger a destroy on the application if the last owner is being destroyed. Also want to destroy memberships when either the user or the application is destroyed, which makes things tricky.