Can’t I just write off my investment after the company declares bankruptcy?

You might have to wait until the final, non-appealable discharge from bankruptcy, which could take years.  To realize your tax loss in the current year, sell your asset now to CapGain Solutions.