Make sure it is receiving plenty of water, as squash require lots of water throughout the growing season. Remove the dead fruit by pulling or cut with a sharp knife. Adding phosphorus to the soil will help encourage additional flowering, which produces fruit.
If fruiting is an issue--growing slowly and then dying--poor pollination could be to blame. Here is an article or two that you may find helpful: https://www.gardeningknowhow.com/edible/vegetables/zucchini/zucchini-fruit-fall-off-the-plant-before-they-are-full-grown.htm