It depends on the day and time you’re there. Weekdays can have really horrible traffic. I haven’t ridden the train into town, but if it’s not working, you’d need to alot 1-2 hours each way for a taxi.
While Jakarta is pretty safe, there have been sporadic reports of thefts on public transport. Personally, I wouldn’t leave the airport on a less than 8-9 hour layover.