Handling activerecord statement invalid exception during sidekiq shutdown

Fix https://github.com/mperham/sidekiq/issues/897